Skip to content

Commit 572ddc6

Browse files
committed
Add back commit cache because of name-rev
Signed-off-by: Filip Navara <[email protected]>
1 parent 0e462d8 commit 572ddc6

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

modules/git/repo.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import (
2727
type Repository struct {
2828
Path string
2929

30-
tagCache *ObjectCache
30+
commitCache *ObjectCache
31+
tagCache *ObjectCache
3132

3233
gogitRepo *gogit.Repository
3334
gogitStorage *filesystem.Storage
@@ -95,6 +96,7 @@ func OpenRepository(repoPath string) (*Repository, error) {
9596
Path: repoPath,
9697
gogitRepo: gogitRepo,
9798
gogitStorage: storage,
99+
commitCache: newObjectCache(),
98100
tagCache: newObjectCache(),
99101
}, nil
100102
}

modules/git/repo_commit.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ func (repo *Repository) GetTagCommitID(name string) (string, error) {
4343
}
4444

4545
func (repo *Repository) getCommit(id SHA1) (*Commit, error) {
46-
//c, ok := repo.commitCache.Get(id.String())
47-
//if ok {
48-
// log("Hit cache: %s", id)
49-
// return c.(*Commit), nil
50-
//}
46+
c, ok := repo.commitCache.Get(id.String())
47+
if ok {
48+
log("Hit cache: %s", id)
49+
return c.(*Commit), nil
50+
}
5151

5252
gogitCommit, err := repo.gogitRepo.CommitObject(plumbing.Hash(id))
5353
if err != nil {
@@ -72,7 +72,7 @@ func (repo *Repository) getCommit(id SHA1) (*Commit, error) {
7272

7373
// name-rev commitID output will be "COMMIT_ID master" or "COMMIT_ID master~12"
7474
commit.Branch = strings.Split(strings.Split(string(data), " ")[1], "~")[0]
75-
//repo.commitCache.Set(id.String(), commit)
75+
repo.commitCache.Set(id.String(), commit)
7676

7777
return commit, nil
7878
}

0 commit comments

Comments
 (0)