From a2f90ce937b55b7f6d9c1fd887b15aceaec51766 Mon Sep 17 00:00:00 2001 From: Jaime Lennox Date: Thu, 19 Jul 2018 15:50:39 +0100 Subject: [PATCH] Check MR is mergeable before accepting MR It's useful to check that we are still able to merge the MR after it has finished CI. Whilst we can check the error message afterwards, these are not always clearer and we'd essentially be doing the same checks as these anyway. As an extra advantage, we also refuse to merge if someone has since unassigned from Marge (something that people tend to do without realising it has no effect after Marge has run it's preflight checks). --- marge/single_merge_job.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/marge/single_merge_job.py b/marge/single_merge_job.py index de49d5bd..f6c004df 100644 --- a/marge/single_merge_job.py +++ b/marge/single_merge_job.py @@ -68,6 +68,9 @@ def update_merge_request_and_accept(self, approvals): if source_project.only_allow_merge_if_pipeline_succeeds: self.wait_for_ci_to_pass(merge_request, actual_sha) time.sleep(2) + + self.ensure_mergeable_mr(merge_request) + try: merge_request.accept(remove_branch=True, sha=actual_sha) except gitlab.NotAcceptable as err: