(rootDir: string, sinceCommit?: string | null)
| 1631 | * with it); a full `codegraph index` reconciles that. |
| 1632 | */ |
| 1633 | export function getGitChangedFiles(rootDir: string, sinceCommit?: string | null): GitChanges | null { |
| 1634 | try { |
| 1635 | // `git status` only ever describes the WORKING TREE, so a change that has |
| 1636 | // been committed leaves no entry and never enters the candidate set — the |
| 1637 | // hash comparison in getChangedFiles is correct but is never reached for |
| 1638 | // it, and `pendingChanges` reads 0 while the index is genuinely behind |
| 1639 | // (#1829). `sinceCommit` — the commit the index was last brought up to |
| 1640 | // date at — adds the other half: what has been committed since. Callers |
| 1641 | // that hold no such stamp still get exactly what they always did, the |
| 1642 | // working-tree changes. |
| 1643 | const changes: GitChanges = { modified: [], added: [], deleted: [] }; |
| 1644 | // Custom extension → language overrides from the project's codegraph.json, |
| 1645 | // so change detection sees the same custom-extension files the full index does. |
| 1646 | const overrides = loadExtensionOverrides(rootDir); |
| 1647 | const isSource = (filePath: string): boolean => isSourceFile(filePath, overrides, rootDir); |
| 1648 | // A project in a folder below its repository's root (#1636). Git can say |
| 1649 | // nothing about a folder its repository ignores: decline, as the scan |
| 1650 | // does, so callers take the full scan that indexed the project. |
| 1651 | const repoPrefix = gitRepoPrefix(rootDir); |
| 1652 | if (repoPrefix && isIgnoredByEnclosingRepo(rootDir)) return null; |
| 1653 | collectGitStatus(rootDir, '', changes, isSource, loadIncludeIgnoredMatcher(rootDir), loadExcludeMatcher(rootDir), sinceCommit ?? undefined, repoPrefix); |
| 1654 | return changes; |
| 1655 | } catch { |
| 1656 | return null; |
| 1657 | } |
| 1658 | } |
| 1659 | |
| 1660 | /** |
| 1661 | * Metadata key: the commit the index was last brought up to date at. Written by |
no test coverage detected