Skip to content

Commit 035dd1e

Browse files
committed
fix
1 parent 504741c commit 035dd1e

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

services/pull/pull.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,14 +401,14 @@ func AddTestPullRequestTask(opts TestPullRequestOptions) {
401401
continue
402402
}
403403

404-
// create push comment first then check pull request status so the test
405-
// will get a stable result
404+
// create push comment before check pull request status,
405+
// then when the status is mergeable, the comment is already in database, to make testing easy and stable
406406
comment, err := CreatePushPullComment(ctx, opts.Doer, pr, opts.OldCommitID, opts.NewCommitID, opts.IsForcePush)
407407
if err == nil && comment != nil {
408408
notify_service.PullRequestPushCommits(ctx, opts.Doer, pr, comment)
409409
}
410-
// FIXME: since AddTestPullRequestTask was called in a goroutine or a queue worker, is it still necessary to
411-
// call another queue to handle the PR check? Maybe we can use checkPullRequestMergeable directly here?
410+
// The caller can be in a goroutine or a "push queue", "conflict check" can be time-consuming,
411+
// and the concurrency should be limited, so the conflict check will be done in another queue
412412
StartPullRequestCheckImmediately(ctx, pr)
413413
}
414414

services/repository/push.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ func pushUpdateBranch(_ context.Context, repo *repo_model.Repository, pusher *us
310310
}
311311

312312
// only update branch can trigger pull request task because the pull request hasn't been created yet when creating a branch
313-
// since pushUpdateBrach is called in a queue worker, we don't need to call it in a go routine again
314313
testPullRequestOpts := pull_service.TestPullRequestOptions{
315314
RepoID: repo.ID,
316315
Doer: pusher,
@@ -320,14 +319,7 @@ func pushUpdateBranch(_ context.Context, repo *repo_model.Repository, pusher *us
320319
OldCommitID: opts.OldCommitID,
321320
NewCommitID: opts.NewCommitID,
322321
}
323-
if setting.IsInTesting {
324-
// testing mode use immediate queue which runs in the same goroutine which will
325-
// cause a deadlock because checkPullRequestMergeable also needs to acquire the global lock
326-
go pull_service.AddTestPullRequestTask(testPullRequestOpts)
327-
} else {
328-
// real queue will run in a different goroutine so it is safe to call here
329-
pull_service.AddTestPullRequestTask(testPullRequestOpts)
330-
}
322+
go pull_service.AddTestPullRequestTask(testPullRequestOpts)
331323

332324
if isForcePush {
333325
log.Trace("Push %s is a force push", opts.NewCommitID)

tests/integration/pull_comment_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ func testPullCommentRebase(t *testing.T, u *url.URL, session *TestSession) {
6262
doGitPushTestRepositoryFail(dstPath, "base-repo", "local-branch/rebase:test-branch/rebase")(t)
6363
doGitPushTestRepository(dstPath, "--force", "base-repo", "local-branch/rebase:test-branch/rebase")(t)
6464

65-
// FIXME: Both the status of the pull request before pushing and the waiting are mergeable. So that
66-
// if it's fast enough here, the pull request checking might be not process yet.
6765
prIssue := testWaitForPullRequestStatus(t, &issues_model.Issue{Title: testPRTitle}, issues_model.PullRequestStatusMergeable)
6866
comments, err := issues_model.FindComments(t.Context(), &issues_model.FindCommentsOptions{
6967
IssueID: prIssue.ID,

0 commit comments

Comments
 (0)