Skip to content

Commit

Permalink
feat(git): add git branch to CacheKey
Browse files Browse the repository at this point in the history
resolves #6012
  • Loading branch information
heaths authored and JanDeDobbeleer committed Dec 17, 2024
1 parent a7ad857 commit 962e2ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/config/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 3 additions & 1 deletion src/segments/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 962e2ea

Please sign in to comment.