diff --git a/lib/api/github.js b/lib/api/github.js index 0bfc19de0866c847c0262a6f8f442a1814245a4d..d3ae2f41574a0a63aa6af820b5f524936880d39a 100644 --- a/lib/api/github.js +++ b/lib/api/github.js @@ -599,7 +599,9 @@ async function getPr(prNo) { const authors = prCommits.reduce((arr, commit) => { logger.trace({ commit }, `Checking commit`); let author = 'unknown'; - if (commit.author) { + if (commit.committer && commit.committer.login) { + author = commit.committer.login; + } else if (commit.author) { author = commit.author.login; } else if (commit.commit && commit.commit.author) { author = commit.commit.author.email; @@ -607,7 +609,8 @@ async function getPr(prNo) { logger.debug('Could not determine commit author'); } logger.debug(`Commit author is: ${author}`); - if (arr.indexOf(author) === -1) { + // Ignore GitHub "web-flow" + if (author !== 'web-flow' && arr.indexOf(author) === -1) { arr.push(author); } return arr; diff --git a/test/api/__snapshots__/github.spec.js.snap b/test/api/__snapshots__/github.spec.js.snap index 053adefe64c5e9876fb1f6b9862eb258f1c16e2f..a86c60bcef8eb6ede4a03fa5f847d3844de07f71 100644 --- a/test/api/__snapshots__/github.spec.js.snap +++ b/test/api/__snapshots__/github.spec.js.snap @@ -849,6 +849,21 @@ Object { } `; +exports[`api/github getPr(prNo) should return a rebaseable PR if web-flow is second author 1`] = ` +Object { + "base": Object { + "sha": "1234", + }, + "canRebase": true, + "commits": 2, + "displayNumber": "Pull Request #1", + "isUnmergeable": true, + "mergeable_state": "dirty", + "number": 1, + "state": "open", +} +`; + exports[`api/github getPr(prNo) should return an unrebaseable PR if multiple authors 1`] = ` Object { "base": Object { diff --git a/test/api/github.spec.js b/test/api/github.spec.js index 262abd3969e3cb7a20341d3190d72b268813f93e..b73680c6a1bbb890c32be947e340a0b71334f868 100644 --- a/test/api/github.spec.js +++ b/test/api/github.spec.js @@ -1167,6 +1167,35 @@ describe('api/github', () => { const pr = await github.getPr(1234); expect(pr).toMatchSnapshot(); }); + it('should return a rebaseable PR if web-flow is second author', async () => { + await initRepo('some/repo', 'token'); + get.mockImplementationOnce(() => ({ + body: { + number: 1, + state: 'open', + mergeable_state: 'dirty', + base: { sha: '1234' }, + commits: 2, + }, + })); + get.mockImplementationOnce(() => ({ + body: [ + { + author: { + login: 'foo', + }, + }, + { + committer: { + login: 'web-flow', + }, + }, + ], + })); + const pr = await github.getPr(1234); + expect(pr.canRebase).toBe(true); + expect(pr).toMatchSnapshot(); + }); }); describe('getAllPrs()', () => { it('maps results to simple array', async () => {