Skip to content

Commit b6947e7

Browse files
committed
fix: include previously-indexed files in incremental and --files modes (audit #2/#12)
getChangedFiles() hard-filtered by LANG_MAP, silently dropping custom- extension files that were indexed during --full. Now also accepts files already in the files table. --files mode no longer rejects non-standard extensions — warns instead and indexes as text.
1 parent 3888190 commit b6947e7

3 files changed

Lines changed: 8 additions & 15 deletions

File tree

src/application/index-engine.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,11 @@ export function getChangedFiles(db: CodemapDatabase): {
126126
.filter(Boolean)
127127
.map((line: string) => line.slice(3).trim());
128128

129+
const indexedPaths = new Set(getAllFileHashes(db).keys());
129130
const allChanged = [...new Set([...diffFiles, ...statusFiles])].filter(
130131
(f) => {
131132
const ext = extname(f);
132-
return ext in LANG_MAP;
133+
return ext in LANG_MAP || indexedPaths.has(f);
133134
},
134135
);
135136

src/application/run-index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { extname } from "node:path";
2-
31
import { createSchema, getAllFileHashes, setMeta } from "../db";
42
import type { CodemapDatabase } from "../db";
53
import {
@@ -9,7 +7,6 @@ import {
97
getCurrentCommit,
108
indexFiles,
119
targetedReindex,
12-
VALID_EXTENSIONS,
1310
} from "./index-engine";
1411
import type { IndexResult, IndexTableStats } from "./types";
1512

@@ -82,10 +79,7 @@ export async function runCodemapIndex(
8279
}
8380

8481
if (mode === "files") {
85-
const targetFiles = (options.files ?? []).filter((f) => {
86-
const ext = extname(f);
87-
return VALID_EXTENSIONS.has(ext);
88-
});
82+
const targetFiles = options.files ?? [];
8983
if (targetFiles.length === 0) {
9084
return {
9185
mode: "files",

src/cli/cmd-index.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ export async function runIndexCmd(opts: {
2020
const db = openDb();
2121
try {
2222
if (args[0] === "--files" && args.length > 1) {
23-
const targetFiles = args.slice(1).filter((f) => {
24-
const ext = extname(f);
25-
if (!VALID_EXTENSIONS.has(ext)) {
26-
console.warn(` Skipping ${f}: unsupported extension "${ext}"`);
27-
return false;
23+
const targetFiles = args.slice(1);
24+
for (const f of targetFiles) {
25+
if (!VALID_EXTENSIONS.has(extname(f))) {
26+
console.warn(` ${f}: non-standard extension, indexing as text`);
2827
}
29-
return true;
30-
});
28+
}
3129
if (targetFiles.length > 0) {
3230
await runCodemapIndex(db, {
3331
mode: "files",

0 commit comments

Comments
 (0)