Skip to content

Commit

Permalink
put param in obj
Browse files Browse the repository at this point in the history
  • Loading branch information
sjschmidt93 authored Jul 10, 2024
1 parent e897571 commit fddef14
Show file tree
Hide file tree
Showing 7 changed files with 30 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.

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

17 changes: 11 additions & 6 deletions src/helpers/approvals-satisfied.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ export class ApprovalsSatisfied extends HelperInputs {
number_of_reviewers?: string;
required_review_overrides?: string;
pull_number?: string;
approvals_not_met_message?: string;
}

export const approvalsSatisfied = async (
{ teams, users, number_of_reviewers = '1', required_review_overrides, pull_number }: ApprovalsSatisfied = {},
approvalsNotMetMessage: string | undefined = undefined
) => {
export const approvalsSatisfied = async ({
teams,
users,
number_of_reviewers = '1',
required_review_overrides,
pull_number,
approvals_not_met_message
}: ApprovalsSatisfied = {}) => {
const prNumber = pull_number ? Number(pull_number) : context.issue.number;

const teamOverrides = required_review_overrides?.split(',').map(overrideString => {
Expand Down Expand Up @@ -94,8 +99,8 @@ export const approvalsSatisfied = async (
if (!approvalsSatisfied) {
logs.unshift('Required approvals not satisfied:\n');

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

await createPrComment({
Expand Down
4 changes: 3 additions & 1 deletion src/helpers/manage-merge-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export const manageMergeQueue = async ({ max_queue_size, login, slack_webhook_ur
core.info('This PR is not in the merge queue.');
return removePrFromQueue(pullRequest);
}
const prMeetsRequiredApprovals = await approvalsSatisfied({}, 'PRs must meet all required approvals before entering the merge queue.');
const prMeetsRequiredApprovals = await approvalsSatisfied({
approvals_not_met_message: 'PRs must meet all required approvals before entering the merge queue.'
});
if (!prMeetsRequiredApprovals) {
return removePrFromQueue(pullRequest);
}
Expand Down
12 changes: 5 additions & 7 deletions test/helpers/approvals-satisfied.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,13 +613,11 @@ Number of required reviews: 1`
}
]
});
await approvalsSatisfied(
{
users: '@user1,@user2',
pull_number: '12345'
},
'PRs must meet all required approvals before entering the merge queue.'
);
await approvalsSatisfied({
users: '@user1,@user2',
pull_number: '12345',
approvals_not_met_message: 'PRs must meet all required approvals before entering the merge queue.'
});
expect(octokit.issues.createComment).toHaveBeenCalledWith(
expect.objectContaining({
body: `PRs must meet all required approvals before entering the merge queue.
Expand Down

0 comments on commit fddef14

Please sign in to comment.