Skip to content

Commit

Permalink
chore: hardcode timeout roles
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Sep 12, 2024
1 parent 13b71cb commit 1ac6ab4
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/helpers/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,22 @@ export interface Requirements {
* statuses, the longest timeout is chosen.
*/
export async function getMergeTimeoutAndApprovalRequiredCount(context: Context, authorAssociation: string): Promise<Requirements> {
const { config: { allowedReviewerRoles } } = context;
const { config: { mergeTimeout, approvalsRequired } } = context;
const timeoutCollaborator = {
mergeTimeout: context.config.mergeTimeout.collaborator,
requiredApprovalCount: context.config.approvalsRequired.collaborator,
mergeTimeout: mergeTimeout.collaborator,
requiredApprovalCount: approvalsRequired.collaborator,
};
const timeoutContributor = {
mergeTimeout: context.config.mergeTimeout.contributor,
requiredApprovalCount: context.config.approvalsRequired.contributor,
mergeTimeout: mergeTimeout.contributor,
requiredApprovalCount: approvalsRequired.contributor,
};
return allowedReviewerRoles.includes(authorAssociation) ? timeoutCollaborator : timeoutContributor;

/**
* Hardcoded roles here because we need to determine the timeouts
* separate from `allowedReviewerRoles` which introduces
* potential unintended user errors and logic issues.
*/
return ["COLLABORATOR", "MEMBER", "OWNER"].includes(authorAssociation) ? timeoutCollaborator : timeoutContributor;
}

export async function getApprovalCount({ octokit, logger, config: { allowedReviewerRoles } }: Context, { owner, repo, issue_number: pullNumber }: IssueParams) {
Expand Down

0 comments on commit 1ac6ab4

Please sign in to comment.