Skip to content

Commit

Permalink
Trim the branch prefix from action.GetBranch
Browse files Browse the repository at this point in the history
 go-gitea#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]>
  • Loading branch information
zeripath committed Dec 14, 2020
1 parent 633dc80 commit 4d30182
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion models/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(git.BranchPrefix, a.RefName)
}

// GetContent returns the action's content.
Expand Down

0 comments on commit 4d30182

Please sign in to comment.