fix(commit): stage file deletions when passed non-existent paths
When check-todos moves a file from pending/ to done/, the commit only staged the new destination. The deletion of the source was never staged because `git add` on a non-existent path is a no-op. Now we detect missing files and use `git rm --cached` to stage the deletion. Closes #1228 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -238,7 +238,13 @@ function cmdCommit(cwd, message, files, raw, amend, noVerify) {
|
||||
// Stage files
|
||||
const filesToStage = files && files.length > 0 ? files : ['.planning/'];
|
||||
for (const file of filesToStage) {
|
||||
execGit(cwd, ['add', file]);
|
||||
const fullPath = path.join(cwd, file);
|
||||
if (!fs.existsSync(fullPath)) {
|
||||
// File was deleted/moved — stage the deletion
|
||||
execGit(cwd, ['rm', '--cached', '--ignore-unmatch', file]);
|
||||
} else {
|
||||
execGit(cwd, ['add', file]);
|
||||
}
|
||||
}
|
||||
|
||||
// Commit (--no-verify skips pre-commit hooks, used by parallel executor agents)
|
||||
|
||||
Reference in New Issue
Block a user