(statusCode: string, rel: string)
| 1769 | // One classifier for both candidate sources below, so a committed change is |
| 1770 | // filtered by exactly the rules a working-tree change is (#766, #999, #1829). |
| 1771 | const classify = (statusCode: string, rel: string): void => { |
| 1772 | const filePath = normalizePath(prefix + rel); |
| 1773 | if (!isSource(filePath)) return; |
| 1774 | |
| 1775 | if (statusCode.includes('D')) { |
| 1776 | // Deletions stay unfiltered: getChangedFiles acts on one only when the |
| 1777 | // path is already tracked in the DB, where removal is always correct — and |
| 1778 | // that lets a newly-excluded dir's stale rows clean themselves up. (#766) |
| 1779 | out.deleted.push(filePath); |
| 1780 | return; |
| 1781 | } |
| 1782 | |
| 1783 | // Added (`??`) / modified files inside an excluded dir must not enter the |
| 1784 | // index — match against the `repoDir`-relative path, same as the full scan. (#766) |
| 1785 | if (ig.ignores(rel)) return; |
| 1786 | // User `codegraph.json` `exclude` (#999) is project-root-relative, so it's |
| 1787 | // matched against the full path — sync must not re-add a tracked file the |
| 1788 | // full index now keeps out. Deletions above stay unfiltered so a file that |
| 1789 | // WAS indexed before an exclude was added still cleans itself out. |
| 1790 | if (exclude && exclude.ignores(filePath)) return; |
| 1791 | |
| 1792 | if (statusCode === '??') { |
| 1793 | out.added.push(filePath); |
| 1794 | } else { |
| 1795 | // M, MM, AM, A (staged), etc. — treat as modified. getChangedFiles |
| 1796 | // re-decides added-vs-modified from the DB, so a committed `A` that the |
| 1797 | // index never saw still lands in `added`. |
| 1798 | out.modified.push(filePath); |
| 1799 | } |
| 1800 | }; |
| 1801 | |
| 1802 | const untrackedDirs: string[] = []; |
| 1803 | for (const line of output.split('\0')) { |
no test coverage detected