handle initial commit for compareUrl

release/v1.15
Christopher Brickley 2014-09-01 19:19:56 -04:00
parent 00a864e693
commit af0741da07
2 changed files with 11 additions and 2 deletions

View File

@ -226,7 +226,11 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
}
repoLink := fmt.Sprintf("%s%s/%s", setting.AppUrl, repoUserName, repoName)
compareUrl := fmt.Sprintf("%s/compare/%s...%s", repoLink, oldCommitId, newCommitId)
compareUrl := ""
// if not the first commit, set the compareUrl
if !strings.HasPrefix(oldCommitId, "0000000") {
compareUrl = fmt.Sprintf("%s/compare/%s...%s", repoLink, oldCommitId, newCommitId)
}
commits := make([]*PayloadCommit, len(commit.Commits))
for i, cmt := range commit.Commits {
commits[i] = &PayloadCommit{

View File

@ -72,10 +72,15 @@ func getSlackPushPayload(p *Payload, slack *Slack) (*SlackPayload, error) {
if len(p.Commits) == 1 {
commitString = "1 new commit"
if p.CompareUrl != "" {
commitString = SlackLinkFormatter(p.CompareUrl, commitString)
}
} else {
commitString = fmt.Sprintf("%d new commits", len(p.Commits))
if p.CompareUrl != "" {
commitString = SlackLinkFormatter(p.CompareUrl, commitString)
}
}
repoLink := SlackLinkFormatter(p.Repo.Url, p.Repo.Name)
branchLink := SlackLinkFormatter(p.Repo.Url+"/src/"+branchName, branchName)