diff --git a/modules/webhook/dingtalk.go b/modules/webhook/dingtalk.go index 4e0e52451ab..a3fda843d5b 100644 --- a/modules/webhook/dingtalk.go +++ b/modules/webhook/dingtalk.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 diff --git a/modules/webhook/discord.go b/modules/webhook/discord.go index 761129d8d9e..7fcca5f8e1a 100644 --- a/modules/webhook/discord.go +++ b/modules/webhook/discord.go @@ -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 diff --git a/modules/webhook/feishu.go b/modules/webhook/feishu.go index 4beda9014c5..dfc335480f4 100644 --- a/modules/webhook/feishu.go +++ b/modules/webhook/feishu.go @@ -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 diff --git a/modules/webhook/matrix.go b/modules/webhook/matrix.go index 68c65623f72..b2bc1968164 100644 --- a/modules/webhook/matrix.go +++ b/modules/webhook/matrix.go @@ -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 { diff --git a/modules/webhook/msteams.go b/modules/webhook/msteams.go index e7ec396f294..812c7ce2190 100644 --- a/modules/webhook/msteams.go +++ b/modules/webhook/msteams.go @@ -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 diff --git a/modules/webhook/slack.go b/modules/webhook/slack.go index 4177bd1250e..8f42d9debe8 100644 --- a/modules/webhook/slack.go +++ b/modules/webhook/slack.go @@ -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 diff --git a/modules/webhook/telegram.go b/modules/webhook/telegram.go index 6d2f804a702..3c43fa1d4ff 100644 --- a/modules/webhook/telegram.go +++ b/modules/webhook/telegram.go @@ -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