mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-28 12:16:17 +01:00
Fix actions workflow branches match bug (#22724)
caused by #22680 `pushPayload.Ref` and `prPayload.PullRequest.Base.Ref` have the format like `refs/heads/<branch_name>`, so we need to trim the prefix before comparing.
This commit is contained in:
parent
98770d3db8
commit
368d43643f
1 changed files with 4 additions and 3 deletions
|
@ -75,7 +75,6 @@ func DetectWorkflows(commit *git.Commit, triggedEvent webhook_module.HookEventTy
|
||||||
if evt.Name != triggedEvent.Event() {
|
if evt.Name != triggedEvent.Event() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if detectMatched(commit, triggedEvent, payload, evt) {
|
if detectMatched(commit, triggedEvent, payload, evt) {
|
||||||
workflows[entry.Name()] = content
|
workflows[entry.Name()] = content
|
||||||
}
|
}
|
||||||
|
@ -105,8 +104,9 @@ func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType
|
||||||
for cond, vals := range evt.Acts {
|
for cond, vals := range evt.Acts {
|
||||||
switch cond {
|
switch cond {
|
||||||
case "branches", "tags":
|
case "branches", "tags":
|
||||||
|
refShortName := git.RefName(pushPayload.Ref).ShortName()
|
||||||
for _, val := range vals {
|
for _, val := range vals {
|
||||||
if glob.MustCompile(val, '/').Match(pushPayload.Ref) {
|
if glob.MustCompile(val, '/').Match(refShortName) {
|
||||||
matchTimes++
|
matchTimes++
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -160,8 +160,9 @@ func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "branches":
|
case "branches":
|
||||||
|
refShortName := git.RefName(prPayload.PullRequest.Base.Ref).ShortName()
|
||||||
for _, val := range vals {
|
for _, val := range vals {
|
||||||
if glob.MustCompile(val, '/').Match(prPayload.PullRequest.Base.Ref) {
|
if glob.MustCompile(val, '/').Match(refShortName) {
|
||||||
matchTimes++
|
matchTimes++
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue