From a5531b871322554105dbc4e85b6f4b911cafadf4 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Wed, 7 Nov 2018 13:19:20 +0100 Subject: [PATCH] fix(gitlab): check branch status for MR mergeability Adds a call to getBranchStatus() from getPr() so that we are correctly calculating pr.canMerge status. Closes #2735 --- lib/platform/gitlab/index.js | 6 ++++-- test/platform/gitlab/index.spec.js | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/platform/gitlab/index.js b/lib/platform/gitlab/index.js index 91ada455bd..6c7f6022fa 100644 --- a/lib/platform/gitlab/index.js +++ b/lib/platform/gitlab/index.js @@ -684,8 +684,10 @@ async function getPr(iid) { pr.canMerge = false; pr.isConflicted = true; } else { - // Actually.. we can't be sure - pr.canMerge = true; + const branchStatus = await getBranchStatus(pr.branchName, []); + if (branchStatus === 'success') { + pr.canMerge = true; + } } // Check if the most recent branch commit is by us // If not then we don't allow it to be rebased, in case someone's changes would be lost diff --git a/test/platform/gitlab/index.spec.js b/test/platform/gitlab/index.spec.js index 4fc3658727..28ba5c7b73 100644 --- a/test/platform/gitlab/index.spec.js +++ b/test/platform/gitlab/index.spec.js @@ -336,6 +336,8 @@ describe('platform/gitlab', () => { }, }, }); + get.mockReturnValueOnce({ body: [] }); // get branch commit + get.mockReturnValueOnce({ body: [{ status: 'success' }] }); // get commit statuses get.mockReturnValueOnce({ body: 'foo' }); const pr = await gitlab.getBranchPr('somebranch'); expect(pr).toMatchSnapshot(); -- GitLab