This repository has been archived by the owner on Sep 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'pavlovcik/feat/contributor-incentives-t…
…otal-scoring' into refactor/type-locations
- Loading branch information
Showing
5 changed files
with
296 additions
and
267 deletions.
There are no files selected for viewing
36 changes: 11 additions & 25 deletions
36
src/handlers/comment/handlers/issue/get-collaborator-ids-for-repo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,18 @@ | ||
import { Context } from "../../../../types/context"; | ||
import { Payload, User } from "../../../../types/payload"; | ||
import { User } from "../../../../types/payload"; | ||
|
||
export async function getCollaboratorsForRepo(context: Context): Promise<User[]> { | ||
const payload = context.event.payload as Payload; | ||
const collaboratorUsers: User[] = []; | ||
const payload = context.payload; | ||
|
||
try { | ||
let page = 1; | ||
let shouldFetch = true; | ||
|
||
while (shouldFetch) { | ||
const res = await context.event.octokit.rest.repos.listCollaborators({ | ||
owner: payload.repository.owner.login, | ||
repo: payload.repository.name, | ||
per_page: 100, | ||
page: page, | ||
}); | ||
|
||
if (res.data.length > 0) { | ||
res.data.forEach((collaborator) => collaboratorUsers.push(collaborator as User)); | ||
page++; | ||
} else { | ||
shouldFetch = false; | ||
} | ||
} | ||
} catch (e: unknown) { | ||
context.logger.error("Fetching collaborator IDs for repo failed!", e); | ||
const collaboratorUsers = (await context.octokit.paginate(context.octokit.rest.repos.listCollaborators, { | ||
owner: payload.repository.owner.login, | ||
repo: payload.repository.name, | ||
per_page: 100, | ||
})) as User[]; | ||
return collaboratorUsers; | ||
} catch (err: unknown) { | ||
context.logger.error("Failed to fetch lists of collaborators", err); | ||
return []; | ||
} | ||
|
||
return collaboratorUsers; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.