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