Browse Source

more fixes on #2045

tags/v0.9.99
Unknwon 8 years ago
parent
commit
e0bae9547a
1 changed files with 9 additions and 9 deletions
  1. 9
    9
      models/webhook_slack.go

+ 9
- 9
models/webhook_slack.go View File

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

Loading…
Cancel
Save