Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vsingal-p committed Apr 2, 2024
1 parent 3463978 commit 36af523
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 28 deletions.
12 changes: 6 additions & 6 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.

12 changes: 6 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.

14 changes: 8 additions & 6 deletions src/helpers/approvals-satisfied.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,21 @@ export class ApprovalsSatisfied extends HelperInputs {

export const approvalsSatisfied = async ({ teams, users, number_of_reviewers = '1', pull_number }: ApprovalsSatisfied = {}) => {
const prNumber = pull_number ? Number(pull_number) : context.issue.number;
const reviews = await paginateAllReviews(prNumber);
const approverLogins = reviews
.filter(({ state }) => state === 'APPROVED')
.map(({ user }) => user?.login)
.filter(Boolean);
core.debug(`PR already approved by: ${approverLogins.toString()}`);

const teamsList = updateTeamsList(teams?.split('\n'));
if (!validateTeamsList(teamsList)) {
core.setFailed('Teams input must be in the format "org/team" or "team". The org must be the same as the repository owner.');
return false;
}
const usersList = users?.split('\n');

const reviews = await paginateAllReviews(prNumber);
const approverLogins = reviews
.filter(({ state }) => state === 'APPROVED')
.map(({ user }) => user?.login)
.filter(Boolean);
core.debug(`PR already approved by: ${approverLogins.toString()}`);

const requiredCodeOwnersEntries =
teamsList || usersList
? createArtificialCodeOwnersEntry({ teams: teamsList, users: usersList })
Expand Down
8 changes: 0 additions & 8 deletions test/helpers/approvals-satisfied.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,6 @@ describe('approvalsSatisfied', () => {
});

it('should throw an error when passing teams override with full name and org is different than repo org', async () => {
mockPagination({
data: [
{
state: 'APPROVED',
user: { login: 'user1' }
}
]
});
const result = await approvalsSatisfied({ teams: 'owner/team2\nsomeOtherOrg/team1', pull_number: '12345' });
expect(getRequiredCodeOwnersEntries).not.toHaveBeenCalled();
expect(core.setFailed).toHaveBeenCalled();
Expand Down

0 comments on commit 36af523

Please sign in to comment.