From ef92d69a8833743e40ad19d48d629b1e25a251bf Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Thu, 12 Jul 2018 07:58:31 +0200 Subject: [PATCH] fix(github): throw error if commit checking fails Closes #2246 --- lib/platform/github/index.js | 35 ++++++++----------- .../github/__snapshots__/index.spec.js.snap | 17 --------- test/platform/github/index.spec.js | 34 ------------------ 3 files changed, 15 insertions(+), 71 deletions(-) diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js index 53d8f1b917..00e0a6acb1 100644 --- a/lib/platform/github/index.js +++ b/lib/platform/github/index.js @@ -919,26 +919,21 @@ async function getPr(prNo) { if (config.gitAuthor) { // Check against gitAuthor logger.debug('Checking all commits'); - try { - const commitAuthorEmail = (await get( - `repos/${config.parentRepo || - config.repository}/pulls/${prNo}/commits` - )).body[0].commit.author.email; - if (commitAuthorEmail === config.gitAuthor.address) { - logger.debug( - { prNo }, - '1 commit matches configured gitAuthor so can rebase' - ); - pr.canRebase = true; - } else { - logger.debug( - { prNo }, - '1 commit and not by configured gitAuthor so cannot rebase' - ); - pr.canRebase = false; - } - } catch (err) { - logger.warn({ prNo }, 'Error checking branch commits for rebase'); + const commitAuthorEmail = (await get( + `repos/${config.parentRepo || + config.repository}/pulls/${prNo}/commits` + )).body[0].commit.author.email; + if (commitAuthorEmail === config.gitAuthor.address) { + logger.debug( + { prNo }, + '1 commit matches configured gitAuthor so can rebase' + ); + pr.canRebase = true; + } else { + logger.debug( + { prNo }, + '1 commit and not by configured gitAuthor so cannot rebase' + ); pr.canRebase = false; } } else { diff --git a/test/platform/github/__snapshots__/index.spec.js.snap b/test/platform/github/__snapshots__/index.spec.js.snap index 084bc8b7c7..a28409a4d1 100644 --- a/test/platform/github/__snapshots__/index.spec.js.snap +++ b/test/platform/github/__snapshots__/index.spec.js.snap @@ -370,23 +370,6 @@ Object { } `; -exports[`platform/github getPr(prNo) should return a not rebaseable PR if gitAuthor and error 1`] = ` -Object { - "base": Object { - "sha": "1234", - }, - "branchName": undefined, - "canRebase": false, - "commits": 1, - "displayNumber": "Pull Request #1", - "isUnmergeable": true, - "mergeable_state": "dirty", - "number": 1, - "sha": undefined, - "state": "open", -} -`; - exports[`platform/github getPr(prNo) should return a not rebaseable PR if gitAuthor does not match 1 commit 1`] = ` Object { "base": Object { diff --git a/test/platform/github/index.spec.js b/test/platform/github/index.spec.js index cf17a619ae..2e69f9a33e 100644 --- a/test/platform/github/index.spec.js +++ b/test/platform/github/index.spec.js @@ -1417,40 +1417,6 @@ describe('platform/github', () => { expect(pr.canRebase).toBe(false); expect(pr).toMatchSnapshot(); }); - it('should return a not rebaseable PR if gitAuthor and error', async () => { - await initRepo({ - repository: 'some/repo', - token: 'token', - gitAuthor: 'Renovate Bot <bot@renovateapp.com>', - }); - get.mockImplementationOnce(() => ({ - body: { - number: 1, - state: 'open', - mergeable_state: 'dirty', - base: { sha: '1234' }, - commits: 1, - }, - })); - get.mockImplementationOnce(() => ({ - body: [ - { - commit: {}, - }, - ], - })); - // getBranchCommit - get.mockImplementationOnce(() => ({ - body: { - object: { - sha: '1234', - }, - }, - })); - const pr = await github.getPr(1234); - expect(pr.canRebase).toBe(false); - expect(pr).toMatchSnapshot(); - }); }); describe('getPrFiles()', () => { it('should return empty if no prNo is passed', async () => { -- GitLab