Skip to content

Commit

Permalink
Unify debug messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Feb 20, 2021
1 parent 1605dd1 commit 46b8b95
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 35 deletions.
30 changes: 14 additions & 16 deletions 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.

33 changes: 15 additions & 18 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,29 @@ export function isAuthorAllowed(
return authorAssociations.includes(pullRequestOrReview.author_association)
}

export function isApprovedByAllowedAuthor(review: Review, reviewAuthorAssociations: string[]): boolean {
if (!isApproved(review)) {
core.debug(`Review ${review.id} is not an approval.`)
return false
}

if (!isAuthorAllowed(review, reviewAuthorAssociations)) {
export function isReviewAuthorAllowed(review: Review, authorAssociations: string[]): boolean {
if (!isAuthorAllowed(review, authorAssociations)) {
core.debug(
`Review ${review.id} is approved, however author @${review.user?.login} ` +
`Author @${review.user?.login} of review ${review.id} ` +
`is ${review.author_association} but must be one of the following:` +
`${reviewAuthorAssociations.join(', ')}`
`${authorAssociations.join(', ')}`
)

return false
}

return true
}

export function isApprovedByAllowedAuthor(review: Review, authorAssociations: string[]): boolean {
if (!isApproved(review)) {
core.debug(`Review ${review.id} is not an approval.`)
return false
}

return isReviewAuthorAllowed(review, authorAssociations)
}

export function relevantReviewsForCommit(
reviews: Review[],
reviewAuthorAssociations: string[],
Expand All @@ -60,15 +65,7 @@ export function relevantReviewsForCommit(
return false
}

const isReviewAuthorAllowed = isAuthorAllowed(review, reviewAuthorAssociations)
if (!isReviewAuthorAllowed) {
core.debug(
`Author @${review.user?.login} (${review.author_association}) of review ${review.id} for commit ${commit} is not allowed.`
)
return false
}

return true
return isReviewAuthorAllowed(review, reviewAuthorAssociations)
})
.sort((a, b) => {
const submittedA = a.submitted_at
Expand Down

0 comments on commit 46b8b95

Please sign in to comment.