Skip to content

Commit

Permalink
feat: add optional only-labels input
Browse files Browse the repository at this point in the history
  • Loading branch information
zubin committed May 28, 2024
1 parent 732147c commit 1bcf355
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
5 changes: 4 additions & 1 deletion dist/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/index.js.map

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions src/__tests__/octokit-queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,30 @@ describe('getTeamSlugsForAuthor', () => {
expect(teamSlugs).toStrictEqual(['team-active']);
});
});

describe('with only teams', () => {
beforeEach(async () => {
teamSlugs = await getTeamSlugsForAuthor(octokit, 'ORG', 'USER', [], ['team-active']);
});

it('should return filtered teams', () => {
expect(teamSlugs).toStrictEqual(['team-active']);
});
});

describe('with only/ignored teams', () => {
beforeEach(async () => {
teamSlugs = await getTeamSlugsForAuthor(
octokit,
'ORG',
'USER',
['team-active'],
['team-active'],
);
});

it('applies ignored teams', () => {
expect(teamSlugs).toStrictEqual([]);
});
});
});
5 changes: 5 additions & 0 deletions src/octokit-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const getTeamSlugsForAuthor = async (
org: string,
username: string,
ignoreSlugs: string[] = [],
onlySlugs: string[] = [],
): Promise<string[]> => {
const { data: allTeams } = await octokit.rest.teams.list({
org,
Expand All @@ -18,6 +19,10 @@ export const getTeamSlugsForAuthor = async (
continue;
}

if (onlySlugs.length > 0 && !onlySlugs.includes(slug)) {
continue;
}

try {
const { data: membership } = await octokit.rest.teams.getMembershipForUserInOrg({
org,
Expand Down

0 comments on commit 1bcf355

Please sign in to comment.