diff options
author | Christopher Brickley <brickley@gmail.com> | 2014-09-01 19:19:56 -0400 |
---|---|---|
committer | Christopher Brickley <brickley@gmail.com> | 2014-09-01 19:19:56 -0400 |
commit | af0741da07ec190804fff2a84c3813fc62a1c3ba (patch) | |
tree | 87ca44e3ed68fe111d16be285f17ff2e52f846b4 /models | |
parent | 00a864e693434bce687f3f5145d8369583197b78 (diff) | |
download | gitea-af0741da07ec190804fff2a84c3813fc62a1c3ba.tar.gz gitea-af0741da07ec190804fff2a84c3813fc62a1c3ba.zip |
handle initial commit for compareUrl
Diffstat (limited to 'models')
-rw-r--r-- | models/action.go | 6 | ||||
-rw-r--r-- | models/slack.go | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/models/action.go b/models/action.go index 5a8c31697c..f739fc353d 100644 --- a/models/action.go +++ b/models/action.go @@ -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{ diff --git a/models/slack.go b/models/slack.go index 714b2f6ca2..3dd40759af 100644 --- a/models/slack.go +++ b/models/slack.go @@ -72,9 +72,14 @@ 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)) - commitString = SlackLinkFormatter(p.CompareUrl, commitString) + if p.CompareUrl != "" { + commitString = SlackLinkFormatter(p.CompareUrl, commitString) + } } repoLink := SlackLinkFormatter(p.Repo.Url, p.Repo.Name) |