diff --git a/accept_merge_request.py b/accept_merge_request.py index 7500bbe98fc152075fcb66c9c6623223f623090f..4e35baf9bae32412648e3e225137bda5db851900 100755 --- a/accept_merge_request.py +++ b/accept_merge_request.py @@ -56,6 +56,17 @@ def accept_merge_request(project, mr, rebase=False, should_remove_source_branch= if e.response_code == 405: # Not allowed (draft, closed, pipeline pending or failed) + # Contrary to the documentation, this response is also issued when the + # merge failed due to a merge conflict. See GitLab issue: + # https://gitlab.com/gitlab-org/gitlab/-/issues/364102 + + if mr.has_conflicts: + # Merge conflict, automatic rebase not possible + if pipeline_pending: + print("") + print("Merge not possible, has to be rebased manually") + return False, mr.sha + # If pipeline is running, wait for completion if not mr.head_pipeline: # No pipeline created yet @@ -69,10 +80,10 @@ def accept_merge_request(project, mr, rebase=False, should_remove_source_branch= print(".", end="", flush=True) time.sleep(1) else: - # Merge conflict, automatic rebase not possible + # Merge failed due to some other reason if pipeline_pending: print("") - print("Merge not possible, has to be rebased manually") + print("Merge not possible for unkown reason") return False, mr.sha elif e.response_code == 406: