Skip to content

Commit 76da4bf

Browse files
committed
fix bug
1 parent 72a154a commit 76da4bf

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

services/pull/conflicts.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,6 @@ func checkPullRequestMergeableAndUpdateStatusMergeTree(ctx context.Context, pr *
8383
return fmt.Errorf("OpenRepository: %w", err)
8484
}
8585
defer baseGitRepo.Close()
86-
// 2.1. fetch head commit id into the current repository
87-
// it will be checked in 2 weeks by default from git if the pull request created failure.
88-
if err := gitrepo.FetchRemoteCommit(ctx, pr.BaseRepo, pr.HeadRepo, pr.HeadCommitID); err != nil {
89-
return fmt.Errorf("FetchRemoteCommit: %w", err)
90-
}
9186
}
9287

9388
// 3. Get head commit id
@@ -107,7 +102,15 @@ func checkPullRequestMergeableAndUpdateStatusMergeTree(ctx context.Context, pr *
107102
}
108103
}
109104

110-
// 4. update merge base
105+
// 4. fetch head commit id into the current repository
106+
// it will be checked in 2 weeks by default from git if the pull request created failure.
107+
if !pr.IsSameRepo() {
108+
if err := gitrepo.FetchRemoteCommit(ctx, pr.BaseRepo, pr.HeadRepo, pr.HeadCommitID); err != nil {
109+
return fmt.Errorf("FetchRemoteCommit: %w", err)
110+
}
111+
}
112+
113+
// 5. update merge base
111114
baseCommitID, err := baseGitRepo.GetRefCommitID(git.BranchPrefix + pr.BaseBranch)
112115
if err != nil {
113116
return fmt.Errorf("GetBranchCommitID: can't find commit ID for base: %w", err)
@@ -120,13 +123,13 @@ func checkPullRequestMergeableAndUpdateStatusMergeTree(ctx context.Context, pr *
120123
return nil
121124
}
122125

123-
// 5. if base == head, then it's an ancestor
126+
// 6. if base == head, then it's an ancestor
124127
if pr.HeadCommitID == pr.MergeBase {
125128
pr.Status = issues_model.PullRequestStatusAncestor
126129
return nil
127130
}
128131

129-
// 6. Check for conflicts
132+
// 7. Check for conflicts
130133
conflicted, err := checkConflictsMergeTree(ctx, pr, baseCommitID)
131134
if err != nil {
132135
log.Error("checkConflictsMergeTree: %v", err)

0 commit comments

Comments
 (0)