diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2025-01-16 21:52:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-16 13:52:21 +0000 |
commit | cfc6e21f0680804747b4dee8af50bb12703a223d (patch) | |
tree | 9d035c84f75a3e78a800a7555cc04da8718dcf65 /services/context | |
parent | ab347fd0f7f13b661b5728b4f47e76bc10c2204b (diff) | |
download | gitea-cfc6e21f0680804747b4dee8af50bb12703a223d.tar.gz gitea-cfc6e21f0680804747b4dee8af50bb12703a223d.zip |
Fix incorrect ref usages (#33301)
Fix #33297
By the way, improve some locales
Diffstat (limited to 'services/context')
-rw-r--r-- | services/context/repo.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/services/context/repo.go b/services/context/repo.go index ef54b9cee8..6cd70d139b 100644 --- a/services/context/repo.go +++ b/services/context/repo.go @@ -777,6 +777,18 @@ func repoRefFullName(typ git.RefType, shortName string) git.RefName { } } +func RepoRefByDefaultBranch() func(*Context) { + return func(ctx *Context) { + ctx.Repo.RefFullName = git.RefNameFromBranch(ctx.Repo.Repository.DefaultBranch) + ctx.Repo.BranchName = ctx.Repo.Repository.DefaultBranch + ctx.Repo.Commit, _ = ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.BranchName) + ctx.Repo.CommitsCount, _ = ctx.Repo.GetCommitsCount() + ctx.Data["RefFullName"] = ctx.Repo.RefFullName + ctx.Data["BranchName"] = ctx.Repo.BranchName + ctx.Data["CommitsCount"] = ctx.Repo.CommitsCount + } +} + // RepoRefByType handles repository reference name for a specific type // of repository reference func RepoRefByType(detectRefType git.RefType) func(*Context) { |