grim/hgkeeper

ebc5f568d629
Add a note about downloads and pgp verification to the readme
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
}