Skip to content

Commit

Permalink
cherry-pick(#32189): fix(only-changed): show nice error message about…
Browse files Browse the repository at this point in the history
… shallow clones (#32190)

This PR cherry-picks the following commits:

- 06ffdd6

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
playwrightmachine and github-actions[bot] authored Aug 16, 2024
1 parent b2d6a09 commit 301f179
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/playwright/src/runner/vcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ export async function detectChangedTestFiles(baseCommit: string, configDir: stri
).split('\n').filter(Boolean);
} catch (_error) {
const error = _error as childProcess.SpawnSyncReturns<string>;

const unknownRevision = error.output.some(line => line?.includes('unknown revision'));
if (unknownRevision) {
const isShallowClone = childProcess.execSync('git rev-parse --is-shallow-repository', { encoding: 'utf-8', stdio: 'pipe' }).trim() === 'true';
if (isShallowClone) {
throw new Error([
`The repository is a shallow clone and does not have '${baseCommit}' available locally.`,
`Note that GitHub Actions checkout is shallow by default: https://github.com/actions/checkout`
].join('\n'));
}
}

throw new Error([
`Cannot detect changed files for --only-changed mode:`,
`git ${command}`,
Expand Down

0 comments on commit 301f179

Please sign in to comment.