Avoid sending "0 new commits" webhook

Signed-off-by: Till Faelligen <tfaelligen@gmail.com>
pull/12212/head
Till Faelligen 4 years ago
parent 8d081950e6
commit 1f47ccfacd
  1. 4
      modules/webhook/dingtalk.go
  2. 4
      modules/webhook/discord.go
  3. 4
      modules/webhook/feishu.go
  4. 4
      modules/webhook/matrix.go
  5. 4
      modules/webhook/msteams.go
  6. 4
      modules/webhook/slack.go
  7. 4
      modules/webhook/telegram.go

@ -83,6 +83,10 @@ func getDingtalkForkPayload(p *api.ForkPayload) (*DingtalkPayload, error) {
}
func getDingtalkPushPayload(p *api.PushPayload) (*DingtalkPayload, error) {
if len(p.Commits) == 0 {
return nil, fmt.Errorf("no commits in payload")
}
var (
branchName = git.RefEndName(p.Ref)
commitDesc string

@ -177,6 +177,10 @@ func getDiscordForkPayload(p *api.ForkPayload, meta *DiscordMeta) (*DiscordPaylo
}
func getDiscordPushPayload(p *api.PushPayload, meta *DiscordMeta) (*DiscordPayload, error) {
if len(p.Commits) == 0 {
return nil, fmt.Errorf("no commits in payload")
}
var (
branchName = git.RefEndName(p.Ref)
commitDesc string

@ -66,6 +66,10 @@ func getFeishuForkPayload(p *api.ForkPayload) (*FeishuPayload, error) {
}
func getFeishuPushPayload(p *api.PushPayload) (*FeishuPayload, error) {
if len(p.Commits) == 0 {
return nil, fmt.Errorf("no commits in payload")
}
var (
branchName = git.RefEndName(p.Ref)
commitDesc string

@ -145,6 +145,10 @@ func getMatrixReleasePayload(p *api.ReleasePayload, matrix *MatrixMeta) (*Matrix
}
func getMatrixPushPayload(p *api.PushPayload, matrix *MatrixMeta) (*MatrixPayloadUnsafe, error) {
if len(p.Commits) == 0 {
return nil, fmt.Errorf("no commits in payload")
}
var commitDesc string
if len(p.Commits) == 1 {

@ -196,6 +196,10 @@ func getMSTeamsForkPayload(p *api.ForkPayload) (*MSTeamsPayload, error) {
}
func getMSTeamsPushPayload(p *api.PushPayload) (*MSTeamsPayload, error) {
if len(p.Commits) == 0 {
return nil, fmt.Errorf("no commits in payload")
}
var (
branchName = git.RefEndName(p.Ref)
commitDesc string

@ -189,6 +189,10 @@ func getSlackReleasePayload(p *api.ReleasePayload, slack *SlackMeta) (*SlackPayl
}
func getSlackPushPayload(p *api.PushPayload, slack *SlackMeta) (*SlackPayload, error) {
if len(p.Commits) == 0 {
return nil, fmt.Errorf("no commits in payload")
}
// n new commits
var (
commitDesc string

@ -86,6 +86,10 @@ func getTelegramForkPayload(p *api.ForkPayload) (*TelegramPayload, error) {
}
func getTelegramPushPayload(p *api.PushPayload) (*TelegramPayload, error) {
if len(p.Commits) == 0 {
return nil, fmt.Errorf("no commits in payload")
}
var (
branchName = git.RefEndName(p.Ref)
commitDesc string

Loading…
Cancel
Save