(statusCode: string, rel: string)
| 1806 | // One classifier for both candidate sources below, so a committed change is |
| 1807 | // filtered by exactly the rules a working-tree change is (#766, #999, #1829). |
| 1808 | const classify = (statusCode: string, rel: string): void => { |
| 1809 | const filePath = normalizePath(prefix + rel); |
| 1810 | if (!isSource(filePath)) return; |
| 1811 | |
| 1812 | if (statusCode.includes('D')) { |
| 1813 | // Deletions stay unfiltered: getChangedFiles acts on one only when the |
| 1814 | // path is already tracked in the DB, where removal is always correct — and |
| 1815 | // that lets a newly-excluded dir's stale rows clean themselves up. (#766) |
| 1816 | out.deleted.push(filePath); |
| 1817 | return; |
| 1818 | } |
| 1819 | |
| 1820 | // Added (`??`) / modified files inside an excluded dir must not enter the |
| 1821 | // index — match against the `repoDir`-relative path, same as the full scan. (#766) |
| 1822 | if (ig.ignores(rel)) return; |
| 1823 | // User `codegraph.json` `exclude` (#999) is project-root-relative, so it's |
| 1824 | // matched against the full path — sync must not re-add a tracked file the |
| 1825 | // full index now keeps out. Deletions above stay unfiltered so a file that |
| 1826 | // WAS indexed before an exclude was added still cleans itself out. |
| 1827 | if (exclude && exclude.ignores(filePath)) return; |
| 1828 | |
| 1829 | if (statusCode === '??') { |
| 1830 | out.added.push(filePath); |
| 1831 | } else { |
| 1832 | // M, MM, AM, A (staged), etc. — treat as modified. getChangedFiles |
| 1833 | // re-decides added-vs-modified from the DB, so a committed `A` that the |
| 1834 | // index never saw still lands in `added`. |
| 1835 | out.modified.push(filePath); |
| 1836 | } |
| 1837 | }; |
| 1838 | |
| 1839 | const untrackedDirs: string[] = []; |
| 1840 | for (const line of output.split('\0')) { |
no test coverage detected