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

knotserver/git: construct a more unique cache key

The previous cache key was just the path, so files that are often common
across git repos like '.gitignore' etc. show a cached "last commit" time
from another repository. Pretty funny.

This uses the current plumbing.Hash.String():path as the key which
should theoretically be unique to each repository.

Changed files
+3 -2
knotserver
git
+3 -2
knotserver/git/git.go
···
}
func (g *GitRepo) LastCommitForPath(path string) (*object.Commit, error) {
+
cacheKey := fmt.Sprintf("%s:%s", g.h.String(), path)
cacheMu.RLock()
-
if commit, found := commitCache.Get(path); found {
+
if commit, found := commitCache.Get(cacheKey); found {
cacheMu.RUnlock()
return commit.(*object.Commit), nil
}
···
}
cacheMu.Lock()
-
commitCache.Set(path, commit, 1)
+
commitCache.Set(cacheKey, commit, 1)
cacheMu.Unlock()
return commit, nil