grim/hgkeeper

Use Go 1.22 and update dependencies
default tip
2 months ago, aklitzing
f33f223bc8fe
Use Go 1.22 and update dependencies

Reviewed at https://reviews.imfreedom.org/r/2949/
package hg
import (
"fmt"
"os/exec"
"strings"
"go.uber.org/zap"
)
func TemplatesDir() (string, error) {
templatesDir, err := Config("web.templates").Exec("", "")
if err != nil || templatesDir == "" {
if err != nil {
zap.S().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 {
zap.S().Debugf("raw: %#v\n", string(raw))
return "", err
}
templatesDir = strings.TrimSpace(string(raw))
if templatesDir == "" {
return "", fmt.Errorf("failed to find the templates directory")
}
zap.S().Infof("using %s as the templates directory\n", templatesDir)
}
return templatesDir, nil
}