mirror of
https://github.com/affaan-m/ECC.git
synced 2026-10-26 18:35:05 +00:00
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:
2 files changed
+7
-1
No files matched your search
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user