feat(git): add git branch to CacheKey

resolves #6012
This commit is contained in:
Heath Stewart 2024-12-14 11:38:33 -08:00 committed by Jan De Dobbeleer
parent 283388da6a
commit b869b3ccd0
2 changed files with 6 additions and 3 deletions

View file

@ -223,9 +223,10 @@ func (segment *Segment) restoreCache() bool {
return false
}
data, OK := segment.env.Session().Get(segment.cacheKey())
cacheKey := segment.cacheKey()
data, OK := segment.env.Session().Get(cacheKey)
if !OK {
log.Debug("no cache found for segment: ", segment.Name())
log.Debugf("no cache found for segment: %s, key: %s", segment.Name(), cacheKey)
return false
}

View file

@ -217,7 +217,9 @@ func (g *Git) CacheKey() (string, bool) {
return "", false
}
return dir.Path, true
ref := g.FileContents(dir.Path, "HEAD")
ref = strings.Replace(ref, "ref: refs/heads/", "", 1)
return fmt.Sprintf("%s@%s", dir.Path, ref), true
}
func (g *Git) Commit() *Commit {