From cfc6e21f0680804747b4dee8af50bb12703a223d Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 16 Jan 2025 21:52:21 +0800 Subject: Fix incorrect ref usages (#33301) Fix #33297 By the way, improve some locales --- services/context/repo.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'services/context') 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) { -- cgit v1.2.3