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:08:08 +01:00
parent 152ac2d544
commit e3c9da6753
4 changed files with 59 additions and 6 deletions

View File

@@ -196,6 +196,30 @@ describe('unsafe-pr-checkout-helper', () => {
).rejects.toThrow()
})
it('refuses pull_request_target when repository points at the fork with a .git suffix', async () => {
setContext('pull_request_target', forkPullRequestTargetPayload())
await expect(
check({
qualifiedRepository: `${FORK_QUALIFIED_REPO}.git`,
ref: 'refs/heads/main',
commit: '',
allowUnsafePrCheckout: false
})
).rejects.toThrow()
})
it('strips only one .git suffix from the repository', async () => {
setContext('pull_request_target', forkPullRequestTargetPayload())
await expect(
check({
qualifiedRepository: `${FORK_QUALIFIED_REPO}.git.git`,
ref: 'refs/heads/main',
commit: '',
allowUnsafePrCheckout: false
})
).resolves.toBeUndefined()
})
it('allows pull_request_target checkout of an unrelated third-party repo', async () => {
setContext('pull_request_target', forkPullRequestTargetPayload())
await expect(