aboutsummaryrefslogtreecommitdiffstats
path: root/services/repository/cache.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/repository/cache.go')
-rw-r--r--services/repository/cache.go16
1 files changed, 3 insertions, 13 deletions
diff --git a/services/repository/cache.go b/services/repository/cache.go
index 6fd4fa7250..91351cbf49 100644
--- a/services/repository/cache.go
+++ b/services/repository/cache.go
@@ -5,7 +5,6 @@ package repository
import (
"context"
- "strings"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/cache"
@@ -13,28 +12,19 @@ import (
"code.gitea.io/gitea/modules/setting"
)
-func getRefName(fullRefName string) string {
- if strings.HasPrefix(fullRefName, git.TagPrefix) {
- return fullRefName[len(git.TagPrefix):]
- } else if strings.HasPrefix(fullRefName, git.BranchPrefix) {
- return fullRefName[len(git.BranchPrefix):]
- }
- return ""
-}
-
// CacheRef cachhe last commit information of the branch or the tag
-func CacheRef(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, fullRefName string) error {
+func CacheRef(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, fullRefName git.RefName) error {
if !setting.CacheService.LastCommit.Enabled {
return nil
}
- commit, err := gitRepo.GetCommit(fullRefName)
+ commit, err := gitRepo.GetCommit(fullRefName.String())
if err != nil {
return err
}
if gitRepo.LastCommitCache == nil {
- commitsCount, err := cache.GetInt64(repo.GetCommitsCountCacheKey(getRefName(fullRefName), true), commit.CommitsCount)
+ commitsCount, err := cache.GetInt64(repo.GetCommitsCountCacheKey(fullRefName.ShortName(), true), commit.CommitsCount)
if err != nil {
return err
}