fix: dereference symlinks when snapshotting sensitive paths to .claude-pr/ (#1186)

`cpSync` defaults to `dereference: false`, which means it tries to
recreate symlinks at the destination rather than copying file contents.
When a sensitive path (e.g. CLAUDE.md) is a symlink, this fails with
`ENOENT: no such file or directory, symlink` because `cpSync` attempts
to call `symlink()` without ensuring the parent `.claude-pr/` directory
exists first.

Adding `dereference: true` fixes this by following symlinks and copying
the actual file contents, which is also the correct semantic behavior —
review agents need to inspect the real content, not a symlink that may
not resolve correctly from `.claude-pr/`.

Fixes the action crash when repositories use symlinked CLAUDE.md
(e.g. CLAUDE.md -> AGENTS.md).
This commit is contained in:
Matan Baruch 2026-05-15 01:36:09 +03:00 committed by GitHub
parent bf6d40e068
commit f4d6a11de1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -54,7 +54,7 @@ export function restoreConfigFromBase(baseBranch: string): void {
rmSync(".claude-pr", { recursive: true, force: true });
for (const p of SENSITIVE_PATHS) {
if (existsSync(p)) {
cpSync(p, `.claude-pr/${p}`, { recursive: true });
cpSync(p, `.claude-pr/${p}`, { recursive: true, dereference: true });
}
}
if (existsSync(".claude-pr")) {