Skip to content

Commit

Permalink
fix: contributor's pull-requests do not get merged automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Nov 25, 2024
1 parent 4ef4156 commit b71ef15
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
6 changes: 1 addition & 5 deletions src/helpers/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,13 @@ export async function getMergeTimeoutAndApprovalRequiredCount(context: Context,
mergeTimeout: mergeTimeout?.collaborator,
requiredApprovalCount: approvalsRequired?.collaborator,
};
const timeoutContributor = {
mergeTimeout: mergeTimeout?.contributor,
requiredApprovalCount: approvalsRequired?.contributor,
};

/**
* 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;
return ["COLLABORATOR", "MEMBER", "OWNER"].includes(authorAssociation) ? timeoutCollaborator : null;
}

export async function getApprovalCount({ octokit, logger, config: { allowedReviewerRoles } }: Context, { owner, repo, issue_number: pullNumber }: IssueParams) {
Expand Down
6 changes: 1 addition & 5 deletions src/types/plugin-inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ export const mergeTimeoutSchema = T.Object(
/**
* The timespan to wait before merging a collaborator's pull-request, defaults to 3.5 days.
*/
collaborator: T.String({ default: "3.5 days" }),
/**
* The timespan to wait before merging a contributor's pull-request, defaults to 7 days.
*/
contributor: T.String({ default: "7 days" }),
collaborator: T.String({ default: "3.5 days", description: "The timespan to wait before merging a collaborator's pull-request" }),
},
{ default: {} }
);
Expand Down
5 changes: 1 addition & 4 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,7 @@ describe("Action tests", () => {
{ once: true }
)
);
await expect(githubHelpers.getMergeTimeoutAndApprovalRequiredCount(context, "CONTRIBUTOR")).resolves.toEqual({
mergeTimeout: contributorMergeTimeout,
requiredApprovalCount: contributorMinimumApprovalsRequired,
});
await expect(githubHelpers.getMergeTimeoutAndApprovalRequiredCount(context, "CONTRIBUTOR")).resolves.toEqual(null);
});

it("Should check if the CI tests are all passing", async () => {
Expand Down

0 comments on commit b71ef15

Please sign in to comment.