Skip to content

Commit d6841c5

Browse files
committed
Fix-up missing merge issues
1 parent bdb32c9 commit d6841c5

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

modules/pull/merge.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,7 @@ func Merge(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repositor
9797
return fmt.Errorf("git remote add [%s -> %s]: %s", baseGitRepo.Path, tmpBasePath, errbuf.String())
9898
}
9999

100-
if err := git.NewCommand("fetch", "origin", pr.BaseBranch+":"+baseBranch).RunInDirPipeline(tmpBasePath, nil, &errbuf); err != nil {
101-
return fmt.Errorf("git fetch [%s -> %s]: %s", headRepoPath, tmpBasePath, errbuf.String())
102-
}
103-
104-
if err := git.NewCommand("fetch", "origin", pr.BaseBranch+":original_"+baseBranch).RunInDirPipeline(tmpBasePath, nil, &errbuf); err != nil {
100+
if err := git.NewCommand("fetch", "origin", "--no-tags", pr.BaseBranch+":"+baseBranch, pr.BaseBranch+":original_"+baseBranch).RunInDirPipeline(tmpBasePath, nil, &errbuf); err != nil {
105101
return fmt.Errorf("git fetch [%s -> %s]: %s", headRepoPath, tmpBasePath, errbuf.String())
106102
}
107103

@@ -119,7 +115,7 @@ func Merge(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repositor
119115

120116
trackingBranch := "tracking"
121117
// Fetch head branch
122-
if err := git.NewCommand("fetch", remoteRepoName, pr.HeadBranch+":"+trackingBranch).RunInDirPipeline(tmpBasePath, nil, &errbuf); err != nil {
118+
if err := git.NewCommand("fetch", "--no-tags", remoteRepoName, pr.HeadBranch+":"+trackingBranch).RunInDirPipeline(tmpBasePath, nil, &errbuf); err != nil {
123119
return fmt.Errorf("git fetch [%s -> %s]: %s", headRepoPath, tmpBasePath, errbuf.String())
124120
}
125121

@@ -192,11 +188,11 @@ func Merge(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repositor
192188
return fmt.Errorf("git checkout: %s", errbuf.String())
193189
}
194190
// Rebase before merging
195-
if err := git.NewCommand("rebase", "-q", pr.BaseBranch).RunInDirPipeline(tmpBasePath, nil, &errbuf); err != nil {
191+
if err := git.NewCommand("rebase", "-q", baseBranch).RunInDirPipeline(tmpBasePath, nil, &errbuf); err != nil {
196192
return fmt.Errorf("git rebase [%s -> %s]: %s", headRepoPath, tmpBasePath, errbuf.String())
197193
}
198194
// Checkout base branch again
199-
if err := git.NewCommand("checkout", pr.BaseBranch).RunInDirPipeline(tmpBasePath, nil, &errbuf); err != nil {
195+
if err := git.NewCommand("checkout", baseBranch).RunInDirPipeline(tmpBasePath, nil, &errbuf); err != nil {
200196
return fmt.Errorf("git checkout: %s", errbuf.String())
201197
}
202198
// Merge fast forward
@@ -209,11 +205,11 @@ func Merge(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repositor
209205
return fmt.Errorf("git checkout: %s", errbuf.String())
210206
}
211207
// Rebase before merging
212-
if err := git.NewCommand("rebase", "-q", pr.BaseBranch).RunInDirPipeline(tmpBasePath, nil, &errbuf); err != nil {
208+
if err := git.NewCommand("rebase", "-q", baseBranch).RunInDirPipeline(tmpBasePath, nil, &errbuf); err != nil {
213209
return fmt.Errorf("git rebase [%s -> %s]: %s", headRepoPath, tmpBasePath, errbuf.String())
214210
}
215211
// Checkout base branch again
216-
if err := git.NewCommand("checkout", pr.BaseBranch).RunInDirPipeline(tmpBasePath, nil, &errbuf); err != nil {
212+
if err := git.NewCommand("checkout", baseBranch).RunInDirPipeline(tmpBasePath, nil, &errbuf); err != nil {
217213
return fmt.Errorf("git checkout: %s", errbuf.String())
218214
}
219215
// Prepare merge with commit

0 commit comments

Comments
 (0)