grim/hgkeeper
Clone
Summary
Browse
Changes
Graph
Prepare for the 1.1.0 release
v1.1.0
16 months ago, Gary Kramlich
22d5b3872b43
Prepare for the 1.1.0 release
package
hg
import
(
"fmt"
"os/exec"
"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 read web.templates setting from hg: %v"
,
err
)
}
args
:=
[]
string
{
"/usr/bin/env"
,
"python3"
,
"-c"
,
"from mercurial import templater; print(templater.templatedir().decode('UTF-8'))"
,
}
cmd
:=
exec
.
Command
(
args
[
0
],
args
[
1
:]
...
)
raw
,
err
:=
cmd
.
CombinedOutput
()
if
err
!=
nil
{
log
.
Debugf
(
"raw: %#v\n"
,
string
(
raw
))
return
""
,
err
}
templatesDir
=
strings
.
TrimSpace
(
string
(
raw
))
if
templatesDir
==
""
{
return
""
,
fmt
.
Errorf
(
"failed to find the templates directory"
)
}
log
.
Infof
(
"using %s as the templates directory\n"
,
templatesDir
)
}
return
templatesDir
,
nil
}