mirror of
https://github.com/go-gitea/gitea.git
synced 2025-09-29 19:25:19 +02:00
Use tag's database num commits instead of read the commit counts from git data
This commit is contained in:
parent
bec9233c29
commit
6d5a85007c
@ -927,13 +927,27 @@ func RepoRefByType(detectRefType git.RefType) func(*Context) {
|
|||||||
|
|
||||||
ctx.Data["CanCreateBranch"] = ctx.Repo.CanCreateBranch() // only used by the branch selector dropdown: AllowCreateNewRef
|
ctx.Data["CanCreateBranch"] = ctx.Repo.CanCreateBranch() // only used by the branch selector dropdown: AllowCreateNewRef
|
||||||
|
|
||||||
ctx.Repo.CommitsCount, err = ctx.Repo.GetCommitsCount()
|
// if it's a tag, we just get the commits count from database
|
||||||
if err != nil {
|
if ctx.Repo.RefFullName.IsTag() {
|
||||||
ctx.ServerError("GetCommitsCount", err)
|
rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, ctx.Repo.RefFullName.TagName())
|
||||||
return
|
if err != nil {
|
||||||
|
if repo_model.IsErrReleaseNotExist(err) {
|
||||||
|
ctx.NotFound(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.ServerError("GetRelease", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.Repo.CommitsCount = rel.NumCommits
|
||||||
|
} else {
|
||||||
|
ctx.Repo.CommitsCount, err = ctx.Repo.GetCommitsCount()
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("GetCommitsCount", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.Data["CommitsCount"] = ctx.Repo.CommitsCount
|
||||||
|
ctx.Repo.GitRepo.LastCommitCache = git.NewLastCommitCache(ctx.Repo.CommitsCount, ctx.Repo.Repository.FullName(), ctx.Repo.GitRepo, cache.GetCache())
|
||||||
}
|
}
|
||||||
ctx.Data["CommitsCount"] = ctx.Repo.CommitsCount
|
|
||||||
ctx.Repo.GitRepo.LastCommitCache = git.NewLastCommitCache(ctx.Repo.CommitsCount, ctx.Repo.Repository.FullName(), ctx.Repo.GitRepo, cache.GetCache())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user