From 4c75eef541337838823ca1a6b18bde2131c6a191 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Jul 2026 14:59:45 +0000 Subject: skip running unsafe pr check if input is default (backport #2518 to releases/v3) --- src/input-helper.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/input-helper.ts b/src/input-helper.ts index 2aa71b1..a550a22 100644 --- a/src/input-helper.ts +++ b/src/input-helper.ts @@ -7,7 +7,7 @@ import * as workflowContextHelper from './workflow-context-helper' import {IGitSourceSettings} from './git-source-settings' export async function getInputs(): Promise { - const result = ({} as unknown) as IGitSourceSettings + const result = {} as unknown as IGitSourceSettings // GitHub workspace let githubWorkspacePath = process.env['GITHUB_WORKSPACE'] @@ -137,7 +137,8 @@ export async function getInputs(): Promise { (core.getInput('persist-credentials') || 'false').toUpperCase() === 'TRUE' // Workflow organization ID - result.workflowOrganizationId = await workflowContextHelper.getOrganizationId() + result.workflowOrganizationId = + await workflowContextHelper.getOrganizationId() // Set safe.directory in git global config. result.setSafeDirectory = @@ -153,12 +154,19 @@ export async function getInputs(): Promise { 'TRUE' core.debug(`allow unsafe PR checkout = ${result.allowUnsafePrCheckout}`) - unsafePrCheckoutHelper.assertSafePrCheckout({ - qualifiedRepository, - ref: result.ref, - commit: result.commit, - allowUnsafePrCheckout: result.allowUnsafePrCheckout - }) + // The default self-checkout (this repository with no explicit ref) always + // resolves to the trusted ref/commit GitHub set for the triggering event, so + // the fork-checkout guard only needs to run when the caller customized the + // repository or ref. + const isDefaultCheckout = isWorkflowRepository && !core.getInput('ref') + if (!isDefaultCheckout) { + unsafePrCheckoutHelper.assertSafePrCheckout({ + qualifiedRepository, + ref: result.ref, + commit: result.commit, + allowUnsafePrCheckout: result.allowUnsafePrCheckout + }) + } return result } -- cgit v1.2.3