Skip to content

Commit

Permalink
fix: make sure PRs are reviewed before merged unless the config allow…
Browse files Browse the repository at this point in the history
…s it and it is the owner
  • Loading branch information
christophehurpeau committed Jan 29, 2023
1 parent 445dcf8 commit e95363a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/events/pr-handlers/actions/utils/steps/codeReviewStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ export function calcCodeReviewStep<GroupNames extends string>({
const hasChangesRequested = repoContext.hasChangesRequestedReview(labels);
const hasApproves = repoContext.hasApprovesReview(labels);
const needsReviewGroupNames = repoContext.getNeedsReviewGroupNames(labels);
const isMissingApprobation = repoContext.config.requiresReviewRequest
? !repoContext.hasApprovesReview(labels)
: false;
const isMissingApprobation =
repoContext.config.requiresReviewRequest ||
pullRequest.user?.type === 'Bot' ||
pullRequest.user?.id !== repoContext.accountEmbed.id
? !repoContext.hasApprovesReview(labels)
: false;

return {
state: (() => {
Expand Down
5 changes: 4 additions & 1 deletion src/events/pr-handlers/opened.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ export default function opened(app: Probot, appContext: AppContext): void {
{
reviewGroup: 'dev',
add:
(repoContext.config.requiresReviewRequest || isFromBot) &&
(repoContext.config.requiresReviewRequest ||
isFromBot ||
pullRequest.user.id !==
context.payload.repository.owner.id) &&
!pullRequest.draft
? ['needsReview']
: [],
Expand Down

0 comments on commit e95363a

Please sign in to comment.