Skip to content

Commit

Permalink
Revert "chore: return early in addOrUpdateAPIReviewCheck for forks (e…
Browse files Browse the repository at this point in the history
…lectron#146)"

This reverts commit f3b42b1.
  • Loading branch information
dsanders11 committed Aug 24, 2023
1 parent e5b1f33 commit 87d5998
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/api-review-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,29 @@ 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 (pr.head.repo.fork) {
if (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 = (
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 = 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 resetToNeutral = async () => {
if (!checkRun) return;
Expand Down Expand Up @@ -219,6 +220,9 @@ 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 87d5998

Please sign in to comment.