fix(core): add --no-index to isGitIgnored for tracked file detection (#703)
Without --no-index, git check-ignore only reports files as ignored if they are untracked. Once .planning/ files enter git's index (e.g., from an initial commit before .gitignore was set up), check-ignore returns "not ignored" even when .gitignore explicitly lists .planning/. This means the documented safety net — "if .planning/ is gitignored, commit_docs is automatically false" — silently fails for any repo where .planning/ was ever committed. The --no-index flag checks .gitignore rules regardless of tracking state, matching user expectations. Closes #703 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -124,7 +124,11 @@ function loadConfig(cwd) {
|
|||||||
|
|
||||||
function isGitIgnored(cwd, targetPath) {
|
function isGitIgnored(cwd, targetPath) {
|
||||||
try {
|
try {
|
||||||
execSync('git check-ignore -q -- ' + targetPath.replace(/[^a-zA-Z0-9._\-/]/g, ''), {
|
// --no-index checks .gitignore rules regardless of whether the file is tracked.
|
||||||
|
// Without it, git check-ignore returns "not ignored" for tracked files even when
|
||||||
|
// .gitignore explicitly lists them — a common source of confusion when .planning/
|
||||||
|
// was committed before being added to .gitignore.
|
||||||
|
execSync('git check-ignore -q --no-index -- ' + targetPath.replace(/[^a-zA-Z0-9._\-/]/g, ''), {
|
||||||
cwd,
|
cwd,
|
||||||
stdio: 'pipe',
|
stdio: 'pipe',
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user