Skip to content

Commit 301f179

Browse files
cherry-pick(#32189): fix(only-changed): show nice error message about shallow clones (#32190)
This PR cherry-picks the following commits: - 06ffdd6 Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent b2d6a09 commit 301f179

File tree

1 file changed

+12
-0
lines changed
  • packages/playwright/src/runner

1 file changed

+12
-0
lines changed

packages/playwright/src/runner/vcs.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ export async function detectChangedTestFiles(baseCommit: string, configDir: stri
2727
).split('\n').filter(Boolean);
2828
} catch (_error) {
2929
const error = _error as childProcess.SpawnSyncReturns<string>;
30+
31+
const unknownRevision = error.output.some(line => line?.includes('unknown revision'));
32+
if (unknownRevision) {
33+
const isShallowClone = childProcess.execSync('git rev-parse --is-shallow-repository', { encoding: 'utf-8', stdio: 'pipe' }).trim() === 'true';
34+
if (isShallowClone) {
35+
throw new Error([
36+
`The repository is a shallow clone and does not have '${baseCommit}' available locally.`,
37+
`Note that GitHub Actions checkout is shallow by default: https://github.com/actions/checkout`
38+
].join('\n'));
39+
}
40+
}
41+
3042
throw new Error([
3143
`Cannot detect changed files for --only-changed mode:`,
3244
`git ${command}`,

0 commit comments

Comments
 (0)