webhook: fix getPayloadBranch
This commit is contained in:
parent
79380c209d
commit
df06904f4a
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.
|
||||
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 ""
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue