diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js index 9f2364dea1ab55902033a0a3bb4c536d21a48077..086bd716c995c38fe401983ca3eb489357621808 100644 --- a/lib/platform/github/index.js +++ b/lib/platform/github/index.js @@ -771,6 +771,7 @@ async function getPr(prNo) { // Harmonise PR values pr.displayNumber = `Pull Request #${pr.number}`; if (pr.state === 'open') { + pr.branchName = pr.head ? pr.head.ref : undefined; if (!pr.mergeable || pr.mergeable_state === 'dirty') { logger.debug(`PR is not mergeable`); pr.isUnmergeable = true; diff --git a/lib/platform/gitlab/index.js b/lib/platform/gitlab/index.js index 1e22321ad6e89e7d3c2c0f41ef621a1947d733b1..412b54e09304f270ce8c4e9f71cf5c687eef996b 100644 --- a/lib/platform/gitlab/index.js +++ b/lib/platform/gitlab/index.js @@ -445,6 +445,7 @@ async function getPr(iid) { const url = `projects/${config.repository}/merge_requests/${iid}`; const pr = (await get(url)).body; // Harmonize fields with GitHub + pr.branchName = pr.source_branch; pr.number = pr.iid; pr.displayNumber = `Merge Request #${pr.iid}`; pr.body = pr.description; diff --git a/lib/workers/pr/index.js b/lib/workers/pr/index.js index c0b4d1153fdf219f6772e10a0e16cd5954017e6d..be18ca7cdf0a513bb358da78a9b04eca6335d81e 100644 --- a/lib/workers/pr/index.js +++ b/lib/workers/pr/index.js @@ -349,7 +349,7 @@ async function checkAutoMerge(pr, config) { } // Check branch status const branchStatus = await platform.getBranchStatus( - pr.head.ref, + pr.branchName, config.requiredStatusChecks ); logger.debug(`branchStatus=${branchStatus}`); diff --git a/test/platform/github/__snapshots__/index.spec.js.snap b/test/platform/github/__snapshots__/index.spec.js.snap index a4ae36f63239f57e05f7ed70dba92efc2bff0fd9..201c509622b1493191ad270b412d489aad8fb3ef 100644 --- a/test/platform/github/__snapshots__/index.spec.js.snap +++ b/test/platform/github/__snapshots__/index.spec.js.snap @@ -446,6 +446,7 @@ Object { "base": Object { "sha": "1234", }, + "branchName": undefined, "canRebase": true, "commits": 1, "displayNumber": "Pull Request #1", @@ -461,6 +462,7 @@ Object { "base": Object { "sha": "5678", }, + "branchName": undefined, "canRebase": true, "commits": 1, "displayNumber": "Pull Request #1", @@ -476,6 +478,7 @@ Object { "base": Object { "sha": "1234", }, + "branchName": undefined, "canRebase": true, "commits": 2, "displayNumber": "Pull Request #1", @@ -491,6 +494,7 @@ Object { "base": Object { "sha": "1234", }, + "branchName": undefined, "canRebase": true, "commits": 2, "displayNumber": "Pull Request #1", @@ -506,6 +510,7 @@ Object { "base": Object { "sha": "1234", }, + "branchName": undefined, "commits": 2, "displayNumber": "Pull Request #1", "isUnmergeable": true, diff --git a/test/platform/gitlab/__snapshots__/index.spec.js.snap b/test/platform/gitlab/__snapshots__/index.spec.js.snap index a640f6e4ac36534f62007ea19c676d88e45ac190..77e76b207f4dfc74a80a8101a5e95ef62caa4b2c 100644 --- a/test/platform/gitlab/__snapshots__/index.spec.js.snap +++ b/test/platform/gitlab/__snapshots__/index.spec.js.snap @@ -166,6 +166,7 @@ Object { "sha": "1234", }, "body": undefined, + "branchName": "some-branch", "commits": 1, "deletions": 1, "displayNumber": "Merge Request #91", @@ -202,6 +203,7 @@ Array [ exports[`platform/gitlab getPr(prNo) returns the PR 1`] = ` Object { "body": "a merge request", + "branchName": "some-branch", "canRebase": true, "description": "a merge request", "displayNumber": "Merge Request #12345",