diff options
author | Unknwon <u@gogs.io> | 2015-12-04 15:41:56 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-12-04 15:41:56 -0500 |
commit | e0bae9547af03e5e7c0201faaa9568d6a1cc9e1f (patch) | |
tree | 22e53c8f11514b665e36ca56dd6900d698692855 /models/webhook_slack.go | |
parent | bfe602726626294a3e33b805ec98bf17b347bdbb (diff) | |
download | gitea-e0bae9547af03e5e7c0201faaa9568d6a1cc9e1f.tar.gz gitea-e0bae9547af03e5e7c0201faaa9568d6a1cc9e1f.zip |
more fixes on #2045
Diffstat (limited to 'models/webhook_slack.go')
-rw-r--r-- | models/webhook_slack.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/models/webhook_slack.go b/models/webhook_slack.go index 9f12738aa0..5fd847b8c6 100644 --- a/models/webhook_slack.go +++ b/models/webhook_slack.go @@ -83,19 +83,19 @@ func getSlackPushPayload(p *api.PushPayload, slack *SlackMeta) (*SlackPayload, e // n new commits var ( branchName = git.RefEndName(p.Ref) + commitDesc string commitString string ) if len(p.Commits) == 1 { - commitString = "1 new commit" - if len(p.CompareUrl) > 0 { - commitString = SlackLinkFormatter(p.CompareUrl, commitString) - } + commitDesc = "1 new commit" } else { - commitString = fmt.Sprintf("%d new commits", len(p.Commits)) - if p.CompareUrl != "" { - commitString = SlackLinkFormatter(p.CompareUrl, commitString) - } + commitDesc = fmt.Sprintf("%d new commits", len(p.Commits)) + } + if len(p.CompareUrl) > 0 { + commitString = SlackLinkFormatter(p.CompareUrl, commitDesc) + } else { + commitString = commitDesc } repoLink := SlackLinkFormatter(p.Repo.URL, p.Repo.Name) @@ -114,7 +114,7 @@ func getSlackPushPayload(p *api.PushPayload, slack *SlackMeta) (*SlackPayload, e slackAttachments := []SlackAttachment{{ Fallback: fmt.Sprintf("%s pushed %s to %s/%s: %s", - p.Pusher, commitString, p.Repo.Name, branchName, p.CompareUrl), + p.Pusher, commitDesc, p.Repo.Name, branchName, p.CompareUrl), Color: slack.Color, Text: attachmentText, }} |