Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(approvals-satisfied): only comment when body present #636

Merged
merged 3 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading