forked from tangled.org/core
this repo has no description

knotserver: git: fetch last commit time against current plumbing.Hash

This fixes the bug where paths wouldn't show up in non-default branches.

We were running 'git log' against the bare repository that was pointing
to the default branch, which would then return no output for that
specific path since -- understandably -- the path doesn't exist on the
default branch. This change simply passes the current g.h
(plumbing.Hash) to 'git log' which resolves the path in that ref.

Changed files
+9 -2
knotserver
+1 -1
knotserver/git/git.go
··· 308 308 } 309 309 cacheMu.RUnlock() 310 310 311 - cmd := exec.Command("git", "-C", g.path, "log", "-1", "--format=%H %ct", "--", path) 311 + cmd := exec.Command("git", "-C", g.path, "log", g.h.String(), "-1", "--format=%H %ct", "--", path) 312 312 313 313 var out bytes.Buffer 314 314 cmd.Stdout = &out
+8 -1
knotserver/git/tree.go
··· 2 2 3 3 import ( 4 4 "fmt" 5 + "time" 5 6 6 7 "github.com/go-git/go-git/v5/plumbing/object" 7 8 "tangled.sh/tangled.sh/core/types" ··· 56 57 lastCommit, err := g.LastCommitForPath(fpath) 57 58 if err != nil { 58 59 fmt.Println("error getting last commit time:", err) 59 - continue 60 + // We don't want to skip the file, so worst case lets just 61 + // populate it with "defaults". 62 + lastCommit = &types.LastCommitInfo{ 63 + Hash: g.h, 64 + Message: "", 65 + When: time.Now(), 66 + } 60 67 } 61 68 62 69 nts = append(nts, types.NiceTree{