grim/hgkeeper
Clone
Summary
Browse
Changes
Graph
Remove the explicit write access of admins to the hgkeeper repo.
23 months ago, Gary Kramlich
5389b17b4002
Remove the explicit write access of admins to the hgkeeper repo.
Fixes HGKEEPER-21
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
}