Skip to content

Commit 46b8b95

Browse files
committed
Unify debug messages.
1 parent 1605dd1 commit 46b8b95

File tree

3 files changed

+30
-35
lines changed

3 files changed

+30
-35
lines changed

dist/index.js

+14-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/helpers.ts

+15-18
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,29 @@ export function isAuthorAllowed(
2828
return authorAssociations.includes(pullRequestOrReview.author_association)
2929
}
3030

31-
export function isApprovedByAllowedAuthor(review: Review, reviewAuthorAssociations: string[]): boolean {
32-
if (!isApproved(review)) {
33-
core.debug(`Review ${review.id} is not an approval.`)
34-
return false
35-
}
36-
37-
if (!isAuthorAllowed(review, reviewAuthorAssociations)) {
31+
export function isReviewAuthorAllowed(review: Review, authorAssociations: string[]): boolean {
32+
if (!isAuthorAllowed(review, authorAssociations)) {
3833
core.debug(
39-
`Review ${review.id} is approved, however author @${review.user?.login} ` +
34+
`Author @${review.user?.login} of review ${review.id} ` +
4035
`is ${review.author_association} but must be one of the following:` +
41-
`${reviewAuthorAssociations.join(', ')}`
36+
`${authorAssociations.join(', ')}`
4237
)
38+
4339
return false
4440
}
4541

4642
return true
4743
}
4844

45+
export function isApprovedByAllowedAuthor(review: Review, authorAssociations: string[]): boolean {
46+
if (!isApproved(review)) {
47+
core.debug(`Review ${review.id} is not an approval.`)
48+
return false
49+
}
50+
51+
return isReviewAuthorAllowed(review, authorAssociations)
52+
}
53+
4954
export function relevantReviewsForCommit(
5055
reviews: Review[],
5156
reviewAuthorAssociations: string[],
@@ -60,15 +65,7 @@ export function relevantReviewsForCommit(
6065
return false
6166
}
6267

63-
const isReviewAuthorAllowed = isAuthorAllowed(review, reviewAuthorAssociations)
64-
if (!isReviewAuthorAllowed) {
65-
core.debug(
66-
`Author @${review.user?.login} (${review.author_association}) of review ${review.id} for commit ${commit} is not allowed.`
67-
)
68-
return false
69-
}
70-
71-
return true
68+
return isReviewAuthorAllowed(review, reviewAuthorAssociations)
7269
})
7370
.sort((a, b) => {
7471
const submittedA = a.submitted_at

0 commit comments

Comments
 (0)