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.
Anirudh Oppiliappan 3 days ago 1 files (+3, -2)
Changed files
MODIFIED
knotserver/git/git.go
MODIFIED
knotserver/git/git.go
@@ -300,8 +300,9 @@ return nil}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}@@ -330,7 +331,7 @@ return nil, err}cacheMu.Lock()- commitCache.Set(path, commit, 1)+ commitCache.Set(cacheKey, commit, 1)cacheMu.Unlock()return commit, nil