fix: git cache (#38763)

1. always use "last commit cache"
2. correctly build the cache key for any input (SafeCacheKey)
3. fix the git note "last commit cache FIXME" and avoid OOM
This commit is contained in:
wxiaoguang
2026-08-05 00:17:07 +08:00
committed by GitHub
parent 6347a33b34
commit deccd53c24
26 changed files with 213 additions and 298 deletions
+1 -4
View File
@@ -66,10 +66,7 @@ func (c *Commit) ParentCount() int {
// GetCommitByPath return the commit of relative path object.
func (c *Commit) GetCommitByPath(ctx context.Context, gitRepo *Repository, relpath string) (*Commit, error) {
if gitRepo.LastCommitCache != nil {
return gitRepo.LastCommitCache.GetCommitByPath(ctx, c.ID.String(), relpath)
}
return gitRepo.getCommitByPathWithID(ctx, c.ID, relpath)
return gitRepo.LastCommitCache.GetCommitByPath(ctx, c.ID, relpath)
}
func (c *Commit) Tree() *Tree {