Update issues when a pull request is merged
This commit is contained in:
parent
1675fc4301
commit
3d99ee30c1
|
|
@ -715,8 +715,12 @@ func TransferRepoAction(doer, oldOwner *User, repo *Repository) error {
|
||||||
return transferRepoAction(x, doer, oldOwner, repo)
|
return transferRepoAction(x, doer, oldOwner, repo)
|
||||||
}
|
}
|
||||||
|
|
||||||
func mergePullRequestAction(e Engine, doer *User, repo *Repository, issue *Issue) error {
|
func mergePullRequestAction(e Engine, doer *User, repo *Repository, issue *Issue, commits *PushCommits) (err error) {
|
||||||
return notifyWatchers(e, &Action{
|
if err = UpdateIssuesCommit(doer, repo, commits.Commits); err != nil {
|
||||||
|
log.Error(4, "updateIssuesCommit: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = notifyWatchers(e, &Action{
|
||||||
ActUserID: doer.ID,
|
ActUserID: doer.ID,
|
||||||
ActUser: doer,
|
ActUser: doer,
|
||||||
OpType: ActionMergePullRequest,
|
OpType: ActionMergePullRequest,
|
||||||
|
|
@ -724,12 +728,16 @@ func mergePullRequestAction(e Engine, doer *User, repo *Repository, issue *Issue
|
||||||
RepoID: repo.ID,
|
RepoID: repo.ID,
|
||||||
Repo: repo,
|
Repo: repo,
|
||||||
IsPrivate: repo.IsPrivate,
|
IsPrivate: repo.IsPrivate,
|
||||||
})
|
}); err != nil {
|
||||||
|
return fmt.Errorf("notifyWatchers: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MergePullRequestAction adds new action for merging pull request.
|
// MergePullRequestAction adds new action for merging pull request.
|
||||||
func MergePullRequestAction(actUser *User, repo *Repository, pull *Issue) error {
|
func MergePullRequestAction(actUser *User, repo *Repository, pull *Issue, commits *PushCommits) error {
|
||||||
return mergePullRequestAction(x, actUser, repo, pull)
|
return mergePullRequestAction(x, actUser, repo, pull, commits)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFeedsOptions options for retrieving feeds
|
// GetFeedsOptions options for retrieving feeds
|
||||||
|
|
|
||||||
|
|
@ -379,6 +379,7 @@ func TestMergePullRequestAction(t *testing.T) {
|
||||||
repo := AssertExistsAndLoadBean(t, &Repository{ID: 1, OwnerID: user.ID}).(*Repository)
|
repo := AssertExistsAndLoadBean(t, &Repository{ID: 1, OwnerID: user.ID}).(*Repository)
|
||||||
repo.Owner = user
|
repo.Owner = user
|
||||||
issue := AssertExistsAndLoadBean(t, &Issue{ID: 3, RepoID: repo.ID}).(*Issue)
|
issue := AssertExistsAndLoadBean(t, &Issue{ID: 3, RepoID: repo.ID}).(*Issue)
|
||||||
|
commits := &PushCommits{0, make([]*PushCommit, 0), "", nil}
|
||||||
|
|
||||||
actionBean := &Action{
|
actionBean := &Action{
|
||||||
OpType: ActionMergePullRequest,
|
OpType: ActionMergePullRequest,
|
||||||
|
|
@ -389,7 +390,7 @@ func TestMergePullRequestAction(t *testing.T) {
|
||||||
IsPrivate: repo.IsPrivate,
|
IsPrivate: repo.IsPrivate,
|
||||||
}
|
}
|
||||||
AssertNotExistsBean(t, actionBean)
|
AssertNotExistsBean(t, actionBean)
|
||||||
assert.NoError(t, MergePullRequestAction(user, repo, issue))
|
assert.NoError(t, MergePullRequestAction(user, repo, issue, commits))
|
||||||
AssertExistsAndLoadBean(t, actionBean)
|
AssertExistsAndLoadBean(t, actionBean)
|
||||||
CheckConsistencyFor(t, &Action{})
|
CheckConsistencyFor(t, &Action{})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -445,10 +445,6 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
|
||||||
log.Error(4, "setMerged [%d]: %v", pr.ID, err)
|
log.Error(4, "setMerged [%d]: %v", pr.ID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = MergePullRequestAction(doer, pr.Issue.Repo, pr.Issue); err != nil {
|
|
||||||
log.Error(4, "MergePullRequestAction [%d]: %v", pr.ID, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset cached commit count
|
// Reset cached commit count
|
||||||
cache.Remove(pr.Issue.Repo.GetCommitsCountCacheKey(pr.BaseBranch, true))
|
cache.Remove(pr.Issue.Repo.GetCommitsCountCacheKey(pr.BaseBranch, true))
|
||||||
|
|
||||||
|
|
@ -488,13 +484,18 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
|
||||||
if mergeStyle == MergeStyleMerge {
|
if mergeStyle == MergeStyleMerge {
|
||||||
l.PushFront(mergeCommit)
|
l.PushFront(mergeCommit)
|
||||||
}
|
}
|
||||||
|
commits := ListToPushCommits(l)
|
||||||
|
|
||||||
|
if err = MergePullRequestAction(doer, pr.Issue.Repo, pr.Issue, commits); err != nil {
|
||||||
|
log.Error(4, "MergePullRequestAction [%d]: %v", pr.ID, err)
|
||||||
|
}
|
||||||
|
|
||||||
p := &api.PushPayload{
|
p := &api.PushPayload{
|
||||||
Ref: git.BranchPrefix + pr.BaseBranch,
|
Ref: git.BranchPrefix + pr.BaseBranch,
|
||||||
Before: pr.MergeBase,
|
Before: pr.MergeBase,
|
||||||
After: mergeCommit.ID.String(),
|
After: mergeCommit.ID.String(),
|
||||||
CompareURL: setting.AppURL + pr.BaseRepo.ComposeCompareURL(pr.MergeBase, pr.MergedCommitID),
|
CompareURL: setting.AppURL + pr.BaseRepo.ComposeCompareURL(pr.MergeBase, pr.MergedCommitID),
|
||||||
Commits: ListToPushCommits(l).ToAPIPayloadCommits(pr.BaseRepo.HTMLURL()),
|
Commits: commits.ToAPIPayloadCommits(pr.BaseRepo.HTMLURL()),
|
||||||
Repo: pr.BaseRepo.APIFormat(mode),
|
Repo: pr.BaseRepo.APIFormat(mode),
|
||||||
Pusher: pr.HeadRepo.MustOwner().APIFormat(),
|
Pusher: pr.HeadRepo.MustOwner().APIFormat(),
|
||||||
Sender: doer.APIFormat(),
|
Sender: doer.APIFormat(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user