Skip to content

Commit 4d0c02b

Browse files
committed
use git.RefName
1 parent 401ec9e commit 4d0c02b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

services/webhook/webhook.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,24 @@ func IsValidHookTaskType(name string) bool {
4646
var hookQueue *queue.WorkerPoolQueue[int64]
4747

4848
// getPayloadRef returns the full ref name for hook event, if applicable.
49-
func getPayloadRef(p api.Payloader) string {
49+
func getPayloadRef(p api.Payloader) git.RefName {
5050
switch pp := p.(type) {
5151
case *api.CreatePayload:
5252
switch pp.RefType {
5353
case "branch":
54-
return git.BranchPrefix + pp.Ref
54+
return git.RefNameFromBranch(pp.Ref)
5555
case "tag":
56-
return git.TagPrefix + pp.Ref
56+
return git.RefNameFromTag(pp.Ref)
5757
}
5858
case *api.DeletePayload:
5959
switch pp.RefType {
6060
case "branch":
61-
return git.BranchPrefix + pp.Ref
61+
return git.RefNameFromBranch(pp.Ref)
6262
case "tag":
63-
return git.TagPrefix + pp.Ref
63+
return git.RefNameFromTag(pp.Ref)
6464
}
6565
case *api.PushPayload:
66-
return pp.Ref
66+
return git.RefName(pp.Ref)
6767
}
6868
return ""
6969
}
@@ -149,6 +149,8 @@ func PrepareWebhook(ctx context.Context, w *webhook_model.Webhook, event webhook
149149

150150
// Apply the filter directly to the ref name
151151
if ref := getPayloadRef(p); ref != "" {
152+
// FIXME: here comes the problem, "ref" is the full ref name, but the filter
153+
// But, "checkBranch" check it against "w.BranchFilter", does it make sense?
152154
if !checkBranch(w, ref) {
153155
log.Info("Ref %q doesn't match branch filter %q, skipping", ref, w.BranchFilter)
154156
return nil

0 commit comments

Comments
 (0)