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
···
}
cacheMu.RUnlock()
-
cmd := exec.Command("git", "-C", g.path, "log", "-1", "--format=%H %ct", "--", path)
+
cmd := exec.Command("git", "-C", g.path, "log", g.h.String(), "-1", "--format=%H %ct", "--", path)
var out bytes.Buffer
cmd.Stdout = &out
+8 -1
knotserver/git/tree.go
···
import (
"fmt"
+
"time"
"github.com/go-git/go-git/v5/plumbing/object"
"tangled.sh/tangled.sh/core/types"
···
lastCommit, err := g.LastCommitForPath(fpath)
if err != nil {
fmt.Println("error getting last commit time:", err)
-
continue
+
// We don't want to skip the file, so worst case lets just
+
// populate it with "defaults".
+
lastCommit = &types.LastCommitInfo{
+
Hash: g.h,
+
Message: "",
+
When: time.Now(),
+
}
}
nts = append(nts, types.NiceTree{