Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-incremental-false-positive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@stainless-code/codemap": patch
---

Fix incremental detection reporting unchanged files as "changed" on every run when the working tree has uncommitted modifications. `getChangedFiles` now compares content hashes against the index before including candidates, so only truly modified files enter the indexing pipeline.
17 changes: 11 additions & 6 deletions src/application/index-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,28 @@ export function getChangedFiles(db: CodemapDatabase): {
.filter(Boolean)
.map((line: string) => line.slice(3).trim());

const indexedPaths = new Set(getAllFileHashes(db).keys());
const allChanged = [...new Set([...diffFiles, ...statusFiles])].filter(
const existingHashes = getAllFileHashes(db);
const allCandidates = [...new Set([...diffFiles, ...statusFiles])].filter(
(f) => {
const ext = extname(f);
return ext in LANG_MAP || indexedPaths.has(f);
return ext in LANG_MAP || existingHashes.has(f);
},
);

const changed: string[] = [];
const deleted: string[] = [];

for (const f of allChanged) {
for (const f of allCandidates) {
const absPath = join(getProjectRoot(), f);
let source: string;
try {
statSync(join(getProjectRoot(), f));
changed.push(f);
source = readFileSync(absPath, "utf-8");
} catch {
deleted.push(f);
continue;
}
if (existingHashes.get(f) !== hashContent(source)) {
changed.push(f);
}
}

Expand Down
Loading