Skip to content

Commit 7f85728

Browse files
Trim the branch prefix from action.GetBranch (#13981) (#13986)
Backport #13981 #13882 has revealed that the refname of an action is actually only a refname pattern and necessarily a branch. For examplem pushing to refs/heads/master will result in action with refname refs/heads/master but pushing to master will result in a refname master. The simplest solution to providing a fix here is to trim the prefix therefore this PR proposes this. Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: a1012112796 <[email protected]> Co-authored-by: a1012112796 <[email protected]>
1 parent d2b308a commit 7f85728

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

models/action.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"time"
1414

1515
"code.gitea.io/gitea/modules/base"
16+
"code.gitea.io/gitea/modules/git"
1617
"code.gitea.io/gitea/modules/log"
1718
"code.gitea.io/gitea/modules/setting"
1819
"code.gitea.io/gitea/modules/timeutil"
@@ -243,7 +244,7 @@ func (a *Action) getCommentLink(e Engine) string {
243244

244245
// GetBranch returns the action's repository branch.
245246
func (a *Action) GetBranch() string {
246-
return a.RefName
247+
return strings.TrimPrefix(a.RefName, git.BranchPrefix)
247248
}
248249

249250
// GetContent returns the action's content.

0 commit comments

Comments
 (0)