diff options
author | 无闻 <joe2010xtmf@163.com> | 2014-09-01 20:02:34 -0700 |
---|---|---|
committer | 无闻 <joe2010xtmf@163.com> | 2014-09-01 20:02:34 -0700 |
commit | 85f375433dfb2114477b84350c67e80363747e21 (patch) | |
tree | 87ca44e3ed68fe111d16be285f17ff2e52f846b4 /models/action.go | |
parent | d55c5b9e289c0c97aa51ffe5cb5b77f703cc2a47 (diff) | |
parent | af0741da07ec190804fff2a84c3813fc62a1c3ba (diff) |
Merge pull request #416 from compressed/compare_commits
Add commit compare functionality
Diffstat (limited to 'models/action.go')
-rw-r--r-- | models/action.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/models/action.go b/models/action.go index d536c84d..f739fc35 100644 --- a/models/action.go +++ b/models/action.go @@ -172,7 +172,7 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com // CommitRepoAction adds new action for committing repository. func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, - repoId int64, repoUserName, repoName string, refFullName string, commit *base.PushCommits) error { + repoId int64, repoUserName, repoName string, refFullName string, commit *base.PushCommits, oldCommitId string, newCommitId string) error { opType := COMMIT_REPO // Check it's tag push or branch. @@ -226,6 +226,11 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, } repoLink := fmt.Sprintf("%s%s/%s", setting.AppUrl, repoUserName, repoName) + 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{ @@ -258,6 +263,9 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, Name: repo.Owner.LowerName, Email: repo.Owner.Email, }, + Before: oldCommitId, + After: newCommitId, + CompareUrl: compareUrl, } for _, w := range ws { |