Skip to content

Commit 43d6ad5

Browse files
committed
pull: fix after commit ID is not latest commit in the base branch (gogs#4442)
1 parent 667c40c commit 43d6ad5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

models/pull.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
328328
return nil
329329
}
330330

331-
// TODO: when squash commits, no need to append merge commit.
332331
// It is possible that head branch is not fully sync with base branch for merge commits,
333332
// so we need to get latest head commit and append merge commit manully
334333
// to avoid strange diff commits produced.
@@ -337,7 +336,9 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
337336
log.Error(2, "GetBranchCommit: %v", err)
338337
return nil
339338
}
340-
l.PushFront(mergeCommit)
339+
if mergeStyle == MERGE_STYLE_REGULAR {
340+
l.PushFront(mergeCommit)
341+
}
341342

342343
commits, err := ListToPushCommits(l).ToApiPayloadCommits(pr.BaseRepo.RepoPath(), pr.BaseRepo.HTMLURL())
343344
if err != nil {
@@ -348,7 +349,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
348349
p := &api.PushPayload{
349350
Ref: git.BRANCH_PREFIX + pr.BaseBranch,
350351
Before: pr.MergeBase,
351-
After: pr.MergedCommitID,
352+
After: mergeCommit.ID.String(),
352353
CompareURL: setting.AppURL + pr.BaseRepo.ComposeCompareURL(pr.MergeBase, pr.MergedCommitID),
353354
Commits: commits,
354355
Repo: pr.BaseRepo.APIFormat(nil),

0 commit comments

Comments
 (0)