fix: count file-level tracked yaml and twig as indexed (#357)

This commit is contained in:
luo jiyin
2026-05-28 22:43:49 -05:00
committed by GitHub
parent 54caceae31
commit 839cf63dcb
2 changed files with 47 additions and 2 deletions
+32
View File
@@ -3226,6 +3226,38 @@ export function multiply(a: number, b: number): number {
cg.close();
});
it('should count file-level tracked YAML files as indexed', async () => {
fs.writeFileSync(path.join(tempDir, 'app.yaml'), 'name: test\n');
fs.writeFileSync(path.join(tempDir, 'routes.yml'), 'route: value\n');
const cg = CodeGraph.initSync(tempDir);
const result = await cg.indexAll();
expect(result.success).toBe(true);
expect(result.filesIndexed).toBe(2);
expect(result.filesSkipped).toBe(0);
expect(cg.getFiles().map((f) => f.path).sort()).toEqual(['app.yaml', 'routes.yml']);
cg.close();
});
it('should count file-level tracked YAML/Twig files as indexed in indexFiles()', async () => {
fs.writeFileSync(path.join(tempDir, 'app.yaml'), 'name: test\n');
fs.writeFileSync(path.join(tempDir, 'view.twig'), '{{ title }}\n');
const cg = CodeGraph.initSync(tempDir);
const result = await cg.indexFiles(['app.yaml', 'view.twig']);
expect(result.success).toBe(true);
expect(result.filesIndexed).toBe(2);
expect(result.filesSkipped).toBe(0);
const tracked = cg.getFiles().map((f) => `${f.path}:${f.language}`).sort();
expect(tracked).toEqual(['app.yaml:yaml', 'view.twig:twig']);
cg.close();
});
});
describe('Path Normalization', () => {
+15 -2
View File
@@ -942,7 +942,15 @@ export class ExtractionOrchestrator {
} else if (result.errors.some((e) => e.severity === 'error')) {
filesErrored++;
} else {
filesSkipped++;
// Files with no symbols but no errors (e.g. yaml, twig) are tracked
// at the file level — count them as indexed so the CLI doesn't
// misleadingly report "No files found to index".
const lang = detectLanguage(filePath, content);
if (lang === 'yaml' || lang === 'twig') {
filesIndexed++;
} else {
filesSkipped++;
}
}
}
}
@@ -1108,7 +1116,12 @@ export class ExtractionOrchestrator {
} else if (result.errors.some((e) => e.severity === 'error')) {
filesErrored++;
} else {
filesSkipped++;
const tracked = this.queries.getFileByPath(filePath);
if (tracked && (tracked.language === 'yaml' || tracked.language === 'twig')) {
filesIndexed++;
} else {
filesSkipped++;
}
}
}