Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: return early in addOrUpdateAPIReviewCheck for forks #146

Merged
merged 1 commit into from
Aug 21, 2023
Merged
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
26 changes: 11 additions & 15 deletions src/api-review-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,28 @@ export async function addOrUpdateAPIReviewCheck(octokit: Context['octokit'], pr:

type CommentOrReview = ListReviewsItem & ListCommentsItem;

const fork = pr.head.repo.fork;
const owner = pr.base.repo.owner.login;
const repo = pr.head.repo.name;

if (fork) {
if (pr.head.repo.fork) {
log(
'addOrUpdateAPIReviewCheck',
LogLevel.INFO,
`${pr.number} is a fork - checks will not be created or updated`,
);
// If the PR is a fork PR, return early as the Checks API doesn't work.
return;
}

// Fetch the latest API Review check for the PR.
const checkRun = fork
? null
: (
await octokit.checks.listForRef({
ref: pr.head.sha,
per_page: 100,
owner,
repo,
})
).data.check_runs.find((run) => run.name === API_REVIEW_CHECK_NAME);
const checkRun = (
await octokit.checks.listForRef({
ref: pr.head.sha,
per_page: 100,
owner,
repo,
})
).data.check_runs.find((run) => run.name === API_REVIEW_CHECK_NAME);

const resetToNeutral = async () => {
if (!checkRun) return;
Expand Down Expand Up @@ -220,9 +219,6 @@ export async function addOrUpdateAPIReviewCheck(octokit: Context['octokit'], pr:

const users = { approved, declined, requestedChanges };

// If the PR is a fork PR, return early as the Checks API doesn't work.
if (fork) return users;

// Update the GitHub Check with appropriate API review information.
const updateCheck = async (
opts: Omit<
Expand Down