Skip to content

Commit

Permalink
Avoid sending "0 new commits" webhook
Browse files Browse the repository at this point in the history
Signed-off-by: Till Faelligen <[email protected]>
  • Loading branch information
S7evinK committed Jul 11, 2020
1 parent 8d08195 commit 1f47ccf
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/webhook/dingtalk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions modules/webhook/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions modules/webhook/feishu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions modules/webhook/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions modules/webhook/msteams.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions modules/webhook/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions modules/webhook/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1f47ccf

Please sign in to comment.