Skip to content

Commit

Permalink
chore: return early in addOrUpdateAPIReviewCheck for forks (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsanders11 authored Aug 21, 2023
1 parent bc6dca1 commit f3b42b1
Showing 1 changed file with 11 additions and 15 deletions.
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

0 comments on commit f3b42b1

Please sign in to comment.