diff --git a/lib/platform/gitlab/index.js b/lib/platform/gitlab/index.js index 91ada455bd48feda0a66c39292d4ca137aa8cd1f..6c7f6022facba24e5c7adddfbf6c9e38441d9ac7 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 4fc36587275774b01044a27978a59343ecde4ff3..28ba5c7b73ecf2ebe5dbd9ac9f64fe11dbcc243c 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();