fix(hooks): list modified files from the repository root even with diff.relative

With diff.relative=true, `git diff --name-only` reports paths relative to the working directory, so joining them to the repository root pointed at files that do not exist, and a session in a subdirectory again got no console.log warning. getGitModifiedFiles now runs `git -c diff.relative=false diff --name-only HEAD`. The -c form also works on Git versions older than --no-relative.
This commit is contained in:
L4XB committed 2026-10-22 23:01:26 +02:00
1 parent adf435d36f
commit b02e02dcd2
2 files changed
+7 -1

No files matched your search

+5
View File
@@ -1217,6 +1217,11 @@ async function runTests() {
const result = await runScript(path.join(scriptsDir, 'check-console-log.js'), '{}', {}, appDir);
assert.strictEqual(result.code, 0);
assert.ok(result.stderr.includes('console.log found in packages/app/src/a.ts'), `Should warn about the file, got: ${result.stderr}`);
// diff.relative would make git report paths from the session's directory.
execFileSync('git', ['config', 'diff.relative', 'true'], { cwd: repo });
const relative = await runScript(path.join(scriptsDir, 'check-console-log.js'), '{}', {}, appDir);
assert.ok(relative.stderr.includes('console.log found in packages/app/src/a.ts'), `Should warn with diff.relative, got: ${relative.stderr}`);
} finally {
fs.rmSync(repo, { recursive: true, force: true });
}