webhook: fix getPayloadBranch
(cherry picked from commit df06904f4ac65dea87534dd33db7554b5373b44e)
This commit is contained in:
parent
cd77a78a93
commit
b15d2a6bc7
1 changed files with 7 additions and 9 deletions
|
@ -82,19 +82,17 @@ var hookQueue *queue.WorkerPoolQueue[int64]
|
||||||
|
|
||||||
// getPayloadBranch returns branch for hook event, if applicable.
|
// getPayloadBranch returns branch for hook event, if applicable.
|
||||||
func getPayloadBranch(p api.Payloader) string {
|
func getPayloadBranch(p api.Payloader) string {
|
||||||
|
var ref string
|
||||||
switch pp := p.(type) {
|
switch pp := p.(type) {
|
||||||
case *api.CreatePayload:
|
case *api.CreatePayload:
|
||||||
if pp.RefType == "branch" {
|
ref = pp.Ref
|
||||||
return pp.Ref
|
|
||||||
}
|
|
||||||
case *api.DeletePayload:
|
case *api.DeletePayload:
|
||||||
if pp.RefType == "branch" {
|
ref = pp.Ref
|
||||||
return pp.Ref
|
|
||||||
}
|
|
||||||
case *api.PushPayload:
|
case *api.PushPayload:
|
||||||
if strings.HasPrefix(pp.Ref, git.BranchPrefix) {
|
ref = pp.Ref
|
||||||
return pp.Ref[len(git.BranchPrefix):]
|
}
|
||||||
}
|
if strings.HasPrefix(ref, git.BranchPrefix) {
|
||||||
|
return ref[len(git.BranchPrefix):]
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue