pagr

A 'static site generator', built using dati.
Log | Files | Refs | Atom

commit 5dfa35c6bd3e66fc32d57533f4ce5d4a5bd4f3e4
parent a80cfbbd9097c09291ccdd122efc42060114e19c
Author: gearsix <gearsix@tuta.io>
Date:   Sat, 26 Mar 2022 01:30:52 +0000

added a LookPath('git') check to init()

Diffstat:
Mcontent.go | 8+++++++-
Mpagr.go | 3+++
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/content.go b/content.go @@ -40,12 +40,18 @@ func isContentExt(ext string) int { return -1 } +// FIX this seems to kill performance func gitModTime(fpath string) (mod time.Time, err error) { + if gitBin == "" { + err = fmt.Errorf("git binary not found") + return + } + if fpath, err = filepath.Abs(fpath); err != nil { return } - git := exec.Command("git", "-C", filepath.Dir(fpath), "log", "-1", "--format='%ad'", "--", fpath) + git := exec.Command(gitBin, "-C", filepath.Dir(fpath), "log", "-1", "--format='%ad'", "--", fpath) var out []byte if out, err = git.Output(); err == nil { outstr := strings.ReplaceAll(string(out), "'", "") diff --git a/pagr.go b/pagr.go @@ -5,6 +5,7 @@ import ( "log" "notabug.org/gearsix/suti" "os" + "os/exec" "path/filepath" "strings" ) @@ -12,6 +13,7 @@ import ( const Name = "pagr" const Version = "0.0.0" +var gitBin string var config Config var flagConfig string var flagVerbose bool @@ -42,6 +44,7 @@ func ignoreFile(filepath string) bool { func init() { flag.BoolVar(&flagVerbose, "v", false, "print verbose ilog.") flag.StringVar(&flagConfig, "cfg", "", "path to pagr project configuration file") + gitBin, _ = exec.LookPath("git") } func main() {