Skip to content

Commit

Permalink
feat(approvals-satisfied): only comment when body present (#636)
Browse files Browse the repository at this point in the history
* feat(approvals-satisfied): only comment when there is a body

* fix

* test name
  • Loading branch information
sjschmidt93 authored Jul 11, 2024
1 parent f0a4649 commit a69b425
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 23 deletions.
6 changes: 3 additions & 3 deletions dist/431.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/431.index.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 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.

8 changes: 4 additions & 4 deletions src/helpers/approvals-satisfied.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ export const approvalsSatisfied = async ({

if (body) {
logs.unshift(body + '\n');
}

await createPrComment({
body: logs.join('\n')
});
await createPrComment({
body: logs.join('\n')
});
}
}

core.info(logs.join('\n'));
Expand Down
13 changes: 2 additions & 11 deletions test/helpers/approvals-satisfied.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ describe('approvalsSatisfied', () => {
});

describe('pr comments', () => {
it('should make pr comment when approvals not satisfied', async () => {
it('should not make pr comment when approvals not satisfied and no body', async () => {
mockPagination({
data: [
{
Expand All @@ -592,16 +592,7 @@ describe('approvalsSatisfied', () => {
users: '@user1,@user2',
pull_number: '12345'
});
expect(octokit.issues.createComment).toHaveBeenCalledWith(
expect.objectContaining({
body: `Required approvals not satisfied:
PR already approved by: user3
Required code owners: @user1,@user2
Current number of approvals satisfied for @user1,@user2: 0
Number of required reviews: 1`
})
);
expect(octokit.issues.createComment).not.toHaveBeenCalled();
});

it('should make pr comment including approvalsNotMetMessage when it is passed and approvals not satisfied', async () => {
Expand Down

0 comments on commit a69b425

Please sign in to comment.