Ignore a .git suffix when matching checkout repositories

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Francesco Renzi
2026-12-04 11:13:15 +01:00
parent 5a9e0139f1
commit 830bba2f1c
3 changed files with 68 additions and 4 deletions

10
dist/index.js vendored
View File

@@ -13404,8 +13404,9 @@ function assertSafePrCheckout(input, authToken) {
}
// (B) We cannot check for all fork PR refs so check to see
// if the resolved input points to the fork PR sha we have in the payload
const repository = repositoryIdentity(input.qualifiedRepository);
const repositoryMatchesPrHead = typeof prHeadRepoFullName === 'string' &&
input.qualifiedRepository.toLowerCase() === prHeadRepoFullName.toLowerCase();
repository === prHeadRepoFullName.toLowerCase();
const refMatchesPullPattern = PR_REF_PATTERN.test(input.ref);
const commit = input.commit && input.commit.toLowerCase();
const commitMatchesPrHeadSha = !!commit && prShas.includes(commit);
@@ -13415,7 +13416,7 @@ function assertSafePrCheckout(input, authToken) {
if (eventName === 'workflow_run' &&
!input.ref &&
commit &&
input.qualifiedRepository.toLowerCase() ===
repository ===
`${github.context.repo.owner}/${github.context.repo.repo}`.toLowerCase()) {
return commitIsInWorkflowHistory(authToken, commit).then(isInHistory => {
if (!isInHistory) {
@@ -13434,6 +13435,11 @@ function assertSafePrCheckout(input, authToken) {
`on the actions/checkout step.`);
}
exports.assertSafePrCheckout = assertSafePrCheckout;
// Git transports resolve 'owner/repo.git' to 'owner/repo', so compare
// repositories without one terminal '.git' suffix.
function repositoryIdentity(qualifiedRepository) {
return qualifiedRepository.replace(/\.git$/, '').toLowerCase();
}
function commitIsInWorkflowHistory(authToken, commit) {
return __awaiter(this, void 0, void 0, function* () {
const workflowSha = github.context.sha.toLowerCase();