summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroliverpool <git@olivier.pfad.fr>2024-04-30 09:30:29 +0200
committeroliverpool <git@olivier.pfad.fr>2024-04-30 09:38:35 +0200
commitdf06904f4ac65dea87534dd33db7554b5373b44e (patch)
treebc96220073cb704de388771ce39f38198355fe74
parenttest: webhook fix branch filter tests (diff)
downloadforgejo-df06904f4ac65dea87534dd33db7554b5373b44e.tar.xz
forgejo-df06904f4ac65dea87534dd33db7554b5373b44e.zip
webhook: fix getPayloadBranch
-rw-r--r--services/webhook/webhook.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/services/webhook/webhook.go b/services/webhook/webhook.go
index cf4f2fdfd2..1366ea8e8f 100644
--- a/services/webhook/webhook.go
+++ b/services/webhook/webhook.go
@@ -82,19 +82,17 @@ var hookQueue *queue.WorkerPoolQueue[int64]
// getPayloadBranch returns branch for hook event, if applicable.
func getPayloadBranch(p api.Payloader) string {
+ var ref string
switch pp := p.(type) {
case *api.CreatePayload:
- if pp.RefType == "branch" {
- return pp.Ref
- }
+ ref = pp.Ref
case *api.DeletePayload:
- if pp.RefType == "branch" {
- return pp.Ref
- }
+ ref = pp.Ref
case *api.PushPayload:
- if strings.HasPrefix(pp.Ref, git.BranchPrefix) {
- return pp.Ref[len(git.BranchPrefix):]
- }
+ ref = pp.Ref
+ }
+ if strings.HasPrefix(ref, git.BranchPrefix) {
+ return ref[len(git.BranchPrefix):]
}
return ""
}