From 081449d7a570855f6fb5499510b10136978cfd7f Mon Sep 17 00:00:00 2001 From: Gusted Date: Tue, 12 Apr 2022 18:38:41 +0200 Subject: [PATCH] Don't allow merging PR's which are being conflict checked (#19357) (#19358) * Don't allow merging PR's which are being conflict checked (#19357) - Backport of #19357 - When a PR is still being conflict checked, don't allow the PR to be merged(the merge button could already be visible before e.g. a new commit was pushed to the PR). - Resolves #19352 * Update error message --- services/pull/check.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/pull/check.go b/services/pull/check.go index f3ffa026560..d9af056ea11 100644 --- a/services/pull/check.go +++ b/services/pull/check.go @@ -36,6 +36,7 @@ var ( ErrUserNotAllowedToMerge = errors.New("user not allowed to merge") ErrHasMerged = errors.New("has already been merged") ErrIsWorkInProgress = errors.New("work in progress PRs cannot be merged") + ErrIsChecking = errors.New("cannot merge while conflict checking is in progress") ErrNotMergableState = errors.New("not in mergeable state") ErrDependenciesLeft = errors.New("is blocked by an open dependency") ) @@ -88,6 +89,10 @@ func CheckPullMergable(ctx context.Context, doer *user_model.User, perm *models. return ErrNotMergableState } + if pr.IsChecking() { + return ErrIsChecking + } + if err := CheckPRReadyToMerge(pr, false); err != nil { if models.IsErrNotAllowedToMerge(err) { if force {