grim/hgkeeper
Clone
Summary
Browse
Changes
Graph
make hgweb its own type
2022-03-07, Gary Kramlich
578a90d306a3
make hgweb its own type
package
hg
import
(
"fmt"
"os/exec"
"path/filepath"
"strings"
log
"github.com/sirupsen/logrus"
)
func
TemplatesDir
()
(
string
,
error
)
{
templatesDir
,
err
:=
Config
(
"web.templates"
).
Exec
(
""
,
""
)
if
err
!=
nil
||
templatesDir
==
""
{
if
err
!=
nil
{
log
.
Warnf
(
"failed to get web.templates config setting: %v"
,
err
)
}
args
:=
[]
string
{
"/usr/bin/env"
,
"python3"
,
"-c"
,
"import mercurial;print(mercurial.__path__[0])"
,
}
cmd
:=
exec
.
Command
(
args
[
0
],
args
[
1
:]
...
)
raw
,
err
:=
cmd
.
CombinedOutput
()
if
err
!=
nil
{
return
""
,
err
}
templatesDir
=
strings
.
TrimSpace
(
string
(
raw
))
if
templatesDir
==
""
{
return
""
,
fmt
.
Errorf
(
"failed to find the templates directory"
)
}
templatesDir
=
filepath
.
Join
(
templatesDir
,
"templates"
)
}
return
templatesDir
,
nil
}