Skip to content

Commit

Permalink
Don't ignore blocked pull requests
Browse files Browse the repository at this point in the history
Based on octokit/octokit.net#1763 the
'blocked' state represents "Blocked by a failing/missing required
status check". Since there are no conflicts at this point, a rebase
is possible and might even be able to fix the status checks.
  • Loading branch information
Niek Haarman committed Dec 17, 2020
1 parent ccdb40a commit a4a2f6f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,37 @@ describe('A pull request is eligible', () => {
},
]);
});

it(`when it is rebaseable, the mergeableState is 'blocked' and it has the label '${OPT_IN_LABEL}'`, async () => {
/* Given */
testOpenPullRequestsProvider.openPullRequestsValue = [
{
ownerName: 'owner',
repoName: 'repo',
number: 3,
draft: false,
rebaseable: true,
mergeableState: 'blocked',
labels: [OPT_IN_LABEL],
},
];

/* When */
const results = await retriever.findEligiblePullRequests('owner', 'repo');

/* Then */
expect(results).toStrictEqual([
{
ownerName: 'owner',
repoName: 'repo',
number: 3,
draft: false,
rebaseable: true,
mergeableState: 'blocked',
labels: [OPT_IN_LABEL],
},
]);
});
});

describe('A pull request is not eligible', () => {
Expand All @@ -80,7 +111,7 @@ describe('A pull request is not eligible', () => {
expect(results).toStrictEqual([]);
});

each([['blocked'], ['clean'], ['dirty'], ['unknown'], ['unstable']]).it(
each([['clean'], ['dirty'], ['unknown'], ['unstable']]).it(
"when the mergeableState is '%s'",
async (mergeableState: MergeableState) => {
/* Given */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ export class TestableEligiblePullRequestsRetriever implements EligiblePullReques
return false;
}

if (pullRequestInfo.mergeableState !== 'behind') {
info(`PR #${pullRequestInfo.number} is not 'behind', but: '${pullRequestInfo.mergeableState}'.`);
if (pullRequestInfo.mergeableState !== 'behind' && pullRequestInfo.mergeableState !== 'blocked') {
info(
`PR #${pullRequestInfo.number} is not 'behind' or 'blocked', but: '${pullRequestInfo.mergeableState}'.`,
);
return false;
}

Expand Down

0 comments on commit a4a2f6f

Please sign in to comment.