Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,7 @@ const utils = __importStar(__nccwpck_require__(9277));
const ERROR_PR_ALREADY_EXISTS = 'A pull request already exists for';
const ERROR_PR_REVIEW_TOKEN_SCOPE = 'Validation Failed: "Could not resolve to a node with the global id of';
const ERROR_PR_FORK_COLLAB = `Fork collab can't be granted by someone without permission`;
const ERROR_PR_REVIEWER_NOT_COLLABORATOR = 'Reviews may only be requested from collaborators';
const blobCreationLimit = (0, p_limit_1.default)(8);
class GitHubHelper {
constructor(githubServerHostname, token) {
Expand Down Expand Up @@ -1433,10 +1434,23 @@ class GitHubHelper {
yield this.octokit.rest.pulls.requestReviewers(Object.assign(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { pull_number: pull.number }), requestReviewersParams));
}
catch (e) {
if (utils.getErrorMessage(e).includes(ERROR_PR_REVIEW_TOKEN_SCOPE)) {
const errorMessage = utils.getErrorMessage(e);
if (errorMessage.includes(ERROR_PR_REVIEW_TOKEN_SCOPE)) {
core.error(`Unable to request reviewers. If requesting team reviewers a 'repo' scoped PAT is required.`);
throw e;
}
else if (errorMessage.includes(ERROR_PR_REVIEWER_NOT_COLLABORATOR)) {
core.warning(`Unable to request reviewers. One or more of the users or teams you specified is not a collaborator of this repository.`);
core.warning(`Reviews may only be requested from collaborators. To resolve this issue, you can:`);
core.warning(` 1. Add the user(s) as collaborators to the repository`);
core.warning(` 2. Add the user(s) to a team with repository access and use 'team-reviewers' instead`);
core.warning(` 3. Remove the non-collaborator user(s) from the 'reviewers' input`);
core.warning(`The pull request was created/updated successfully, but reviewer requests were not applied.`);
core.warning(`See: https://docs.github.com/rest/pulls/review-requests#request-reviewers-for-a-pull-request`);
}
else {
throw e;
}
throw e;
}
}
return pull;
Expand Down
31 changes: 29 additions & 2 deletions src/github-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const ERROR_PR_ALREADY_EXISTS = 'A pull request already exists for'
const ERROR_PR_REVIEW_TOKEN_SCOPE =
'Validation Failed: "Could not resolve to a node with the global id of'
const ERROR_PR_FORK_COLLAB = `Fork collab can't be granted by someone without permission`
const ERROR_PR_REVIEWER_NOT_COLLABORATOR =
'Reviews may only be requested from collaborators'

const blobCreationLimit = pLimit(8)

Expand Down Expand Up @@ -207,12 +209,37 @@ export class GitHubHelper {
...requestReviewersParams
})
} catch (e) {
if (utils.getErrorMessage(e).includes(ERROR_PR_REVIEW_TOKEN_SCOPE)) {
const errorMessage = utils.getErrorMessage(e)
if (errorMessage.includes(ERROR_PR_REVIEW_TOKEN_SCOPE)) {
core.error(
`Unable to request reviewers. If requesting team reviewers a 'repo' scoped PAT is required.`
)
throw e
} else if (errorMessage.includes(ERROR_PR_REVIEWER_NOT_COLLABORATOR)) {
core.warning(
`Unable to request reviewers. One or more of the users or teams you specified is not a collaborator of this repository.`
)
core.warning(
`Reviews may only be requested from collaborators. To resolve this issue, you can:`
)
core.warning(
` 1. Add the user(s) as collaborators to the repository`
)
core.warning(
` 2. Add the user(s) to a team with repository access and use 'team-reviewers' instead`
)
core.warning(
` 3. Remove the non-collaborator user(s) from the 'reviewers' input`
)
core.warning(
`The pull request was created/updated successfully, but reviewer requests were not applied.`
)
core.warning(
`See: https://docs.github.com/rest/pulls/review-requests#request-reviewers-for-a-pull-request`
)
} else {
throw e
}
throw e
}
}

Expand Down