mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-26 11:04:27 -04:00
Merge d2b9cab1dada3d46223b70f3c619f1dc0602e5a0 into dd0caf7e163bff3ecd951a045d9cea47efaa7ed5
This commit is contained in:
commit
e290b039fc
@ -161,6 +161,11 @@ func UpdateRelease(ctx context.Context, rel *Release) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func UpdateReleaseNumCommits(ctx context.Context, rel *Release) error {
|
||||
_, err := db.GetEngine(ctx).ID(rel.ID).Cols("num_commits").Update(rel)
|
||||
return err
|
||||
}
|
||||
|
||||
// AddReleaseAttachments adds a release attachments
|
||||
func AddReleaseAttachments(ctx context.Context, releaseID int64, attachmentUUIDs []string) (err error) {
|
||||
// Check attachments
|
||||
|
@ -920,17 +920,40 @@ func RepoRefByType(detectRefType git.RefType) func(*Context) {
|
||||
ctx.Data["RefFullName"] = ctx.Repo.RefFullName
|
||||
ctx.Data["RefTypeNameSubURL"] = ctx.Repo.RefTypeNameSubURL()
|
||||
ctx.Data["TreePath"] = ctx.Repo.TreePath
|
||||
|
||||
ctx.Data["BranchName"] = ctx.Repo.BranchName
|
||||
|
||||
ctx.Data["CommitID"] = ctx.Repo.CommitID
|
||||
|
||||
ctx.Data["CanCreateBranch"] = ctx.Repo.CanCreateBranch() // only used by the branch selector dropdown: AllowCreateNewRef
|
||||
|
||||
ctx.Repo.CommitsCount, err = ctx.Repo.GetCommitsCount()
|
||||
if err != nil {
|
||||
ctx.ServerError("GetCommitsCount", err)
|
||||
return
|
||||
// if it's a tag, we just get the commits count from database
|
||||
if ctx.Repo.RefFullName.IsTag() {
|
||||
rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, ctx.Repo.RefFullName.TagName())
|
||||
if err != nil {
|
||||
if repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.NotFound(err)
|
||||
return
|
||||
}
|
||||
ctx.ServerError("GetRelease", err)
|
||||
return
|
||||
}
|
||||
// for mirror tags, the number of commist may not be set
|
||||
if rel.NumCommits <= 0 {
|
||||
rel.NumCommits, err = ctx.Repo.GetCommitsCount()
|
||||
if err != nil {
|
||||
ctx.ServerError("GetCommitsCount", err)
|
||||
return
|
||||
}
|
||||
if err := repo_model.UpdateReleaseNumCommits(ctx, rel); err != nil {
|
||||
ctx.ServerError("UpdateReleaseNumCommits", 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())
|
||||
|
Loading…
x
Reference in New Issue
Block a user