Browse Source

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

pull/4722/merge
Unknwon 7 years ago
parent
commit
43d6ad5fda
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 7
      models/pull.go

7
models/pull.go

@ -328,7 +328,6 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
return nil 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, // 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 // so we need to get latest head commit and append merge commit manully
// to avoid strange diff commits produced. // 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) log.Error(2, "GetBranchCommit: %v", err)
return nil return nil
} }
l.PushFront(mergeCommit) if mergeStyle == MERGE_STYLE_REGULAR {
l.PushFront(mergeCommit)
}
commits, err := ListToPushCommits(l).ToApiPayloadCommits(pr.BaseRepo.RepoPath(), pr.BaseRepo.HTMLURL()) commits, err := ListToPushCommits(l).ToApiPayloadCommits(pr.BaseRepo.RepoPath(), pr.BaseRepo.HTMLURL())
if err != nil { if err != nil {
@ -348,7 +349,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
p := &api.PushPayload{ p := &api.PushPayload{
Ref: git.BRANCH_PREFIX + pr.BaseBranch, Ref: git.BRANCH_PREFIX + pr.BaseBranch,
Before: pr.MergeBase, Before: pr.MergeBase,
After: pr.MergedCommitID, 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: commits, Commits: commits,
Repo: pr.BaseRepo.APIFormat(nil), Repo: pr.BaseRepo.APIFormat(nil),

Loading…
Cancel
Save