Avoid sending "0 new commits" webhook

Signed-off-by: Till Faelligen <tfaelligen@gmail.com>
This commit is contained in:
Till Faelligen 2020-07-11 13:09:06 +02:00
parent 8d081950e6
commit 1f47ccfacd
7 changed files with 28 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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