]> source.dussan.org Git - gitea.git/commitdiff
Trim the branch prefix from action.GetBranch (#13981)
authorzeripath <art27@cantab.net>
Mon, 14 Dec 2020 17:08:37 +0000 (17:08 +0000)
committerGitHub <noreply@github.com>
Mon, 14 Dec 2020 17:08:37 +0000 (19:08 +0200)
* Trim the branch prefix from action.GetBranch

 #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 <art27@cantab.net>
* Update models/action.go

Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: a1012112796 <1012112796@qq.com>
models/action.go

index 67c60d84f3081b4f896704e9797c96f3c8e1f506..e702a4263c9f1165c4b44ee7be7d8bb620e7d901 100644 (file)
@@ -13,6 +13,7 @@ import (
        "time"
 
        "code.gitea.io/gitea/modules/base"
+       "code.gitea.io/gitea/modules/git"
        "code.gitea.io/gitea/modules/log"
        "code.gitea.io/gitea/modules/setting"
        "code.gitea.io/gitea/modules/timeutil"
@@ -238,7 +239,7 @@ func (a *Action) getCommentLink(e Engine) string {
 
 // GetBranch returns the action's repository branch.
 func (a *Action) GetBranch() string {
-       return a.RefName
+       return strings.TrimPrefix(a.RefName, git.BranchPrefix)
 }
 
 // GetContent returns the action's content.