Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
danadajian committed Sep 12, 2024
1 parent c3cd30d commit f191ba0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
16 changes: 10 additions & 6 deletions dist/676.index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/676.index.js.map

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions src/helpers/prepare-queued-pr-for-merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,17 @@ export const updatePrWithDefaultBranch = async (pullRequest: PullRequest) => {
});
} catch (error) {
const noEvictUponConflict = core.getInput('no_evict_upon_conflict');
if ((error as GithubError).status === 409) {
if (noEvictUponConflict !== 'true') await removePrFromQueue(pullRequest);
core.setFailed('The first PR in the queue has a merge conflict.');
} else core.setFailed((error as GithubError).message);
const githubError = error as GithubError;
if (githubError.status !== 409) {
core.setFailed(githubError.message);
return;
}
if (noEvictUponConflict === 'true') {
core.info('The first PR in the queue has a merge conflict. PR was not removed from the queue due to no_evict_upon_conflict input.');
return;
}

await removePrFromQueue(pullRequest);
core.setFailed('The first PR in the queue has a merge conflict, and it was removed from the queue.');
}
};
4 changes: 2 additions & 2 deletions test/helpers/prepare-queued-pr-for-merge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@ describe('prepareQueuedPrForMerge', () => {
await prepareQueuedPrForMerge();
});

it('should NOT remove PR from queue and call core.error', () => {
it('should NOT remove PR from queue and call core.info', () => {
expect(removePrFromQueue).not.toHaveBeenCalled();
expect(core.setFailed).toHaveBeenCalled();
expect(core.info).toHaveBeenCalled();
});
});

Expand Down

0 comments on commit f191ba0

Please sign in to comment.