forked from forgejo/forgejo
Avoid sending "0 new commits" webhooks (#12212)
* Avoid sending "0 new commits" webhook
Signed-off-by: Till Faelligen <tfaelligen@gmail.com>
* Revert "Avoid sending "0 new commits" webhook"
This reverts commit 1f47ccfacd
.
* Move commit count check to more central place
* Make tests pass
* Update modules/webhook/webhook.go
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
514201af5d
commit
7af2ccd511
2 changed files with 10 additions and 2 deletions
|
@ -76,6 +76,14 @@ func prepareWebhook(w *models.Webhook, repo *models.Repository, event models.Hoo
|
|||
}
|
||||
}
|
||||
|
||||
// Avoid sending "0 new commits" to non-integration relevant webhooks (e.g. slack, discord, etc.).
|
||||
// Integration webhooks (e.g. drone) still receive the required data.
|
||||
if pushEvent, ok := p.(*api.PushPayload); ok &&
|
||||
w.HookTaskType != models.GITEA && w.HookTaskType != models.GOGS &&
|
||||
len(pushEvent.Commits) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
// If payload has no associated branch (e.g. it's a new tag, issue, etc.),
|
||||
// branch filter has no effect.
|
||||
if branch := getPayloadBranch(p); branch != "" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue