Skip to content

Commit

Permalink
fix: do not fail merging on empty PR body (#4658)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-fenster authored Nov 4, 2022
1 parent 4854486 commit 6b43d2c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/merge-on-green/src/merge-logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ async function merge(
repo,
pull_number: pr,
commit_title: `${prInfo.title} (#${pr})`,
commit_message: cleanGHLinks(prInfo.body) || '',
commit_message: cleanGHLinks(prInfo.body || '') || '',
merge_method: 'squash',
})
).data as Merge;
Expand Down
42 changes: 40 additions & 2 deletions packages/merge-on-green/test/merge-logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,14 @@ function getPR(
mergeable: boolean,
mergeableState: string,
state: string,
labels: {name: string}[] = []
labels: {name: string}[] = [],
body: string | null | undefined = 'Test Body'
) {
return nock('https://api.github.com')
.get('/repos/testOwner/testRepo/pulls/1')
.reply(200, {
title: 'Test PR',
body: 'Test Body',
body,
state,
mergeable,
mergeable_state: mergeableState,
Expand Down Expand Up @@ -243,6 +244,43 @@ describe('merge-logic', () => {
scopes.forEach(s => s.done());
});

it('merges a PR with empty body on green', async () => {
const scopes = [
getRateLimit(5000),
mockLatestCommit([{sha: '6dcb09b5b57875f334f61aebed695e2e4193db5e'}]),
getReviewsCompleted([
{
user: {login: 'octocat'},
state: 'APPROVED',
commit_id: '6dcb09b5b57875f334f61aebed695e2e4193db5e',
id: 12345,
},
]),
getStatusi('6dcb09b5b57875f334f61aebed695e2e4193db5e', [
{state: 'success', context: 'Special Check'},
]),
getPR(true, 'clean', 'open', [], /* body: */ null),
getCommentsOnPr([]),
merge(),
removeMogLabel('automerge'),
removeReaction(),
];

await probot.receive({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
name: 'schedule.installation' as any,
payload: {
cron_type: 'installation',
cron_org: 'testOwner',
performMerge: true,
installation: {id: 1234},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
id: 'abc123',
});

scopes.forEach(s => s.done());
});
it('fails when a review has not been approved', async () => {
const scopes = [
getRateLimit(5000),
Expand Down

0 comments on commit 6b43d2c

Please sign in to comment.