pull: fix after commit ID is not latest commit in the base branch (#4442)

This commit is contained in:
Unknwon
2017-11-18 00:38:06 -05:00
parent 667c40c3de
commit 43d6ad5fda

View File

@@ -328,7 +328,6 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
return nil
}
// TODO: when squash commits, no need to append merge commit.
// It is possible that head branch is not fully sync with base branch for merge commits,
// so we need to get latest head commit and append merge commit manully
// to avoid strange diff commits produced.
@@ -337,7 +336,9 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
log.Error(2, "GetBranchCommit: %v", err)
return nil
}
if mergeStyle == MERGE_STYLE_REGULAR {
l.PushFront(mergeCommit)
}
commits, err := ListToPushCommits(l).ToApiPayloadCommits(pr.BaseRepo.RepoPath(), pr.BaseRepo.HTMLURL())
if err != nil {
@@ -348,7 +349,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
p := &api.PushPayload{
Ref: git.BRANCH_PREFIX + pr.BaseBranch,
Before: pr.MergeBase,
After: pr.MergedCommitID,
After: mergeCommit.ID.String(),
CompareURL: setting.AppURL + pr.BaseRepo.ComposeCompareURL(pr.MergeBase, pr.MergedCommitID),
Commits: commits,
Repo: pr.BaseRepo.APIFormat(nil),