MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / canTrustGitFastPath

Function canTrustGitFastPath

src/extraction/index.ts:1755–1768  ·  view source on GitHub ↗
(rootDir: string, sinceCommit?: string | null)

Source from the content-addressed store, hash-verified

1753 * working-tree diff is the whole of what they wanted. (#1829)
1754 */
1755export function canTrustGitFastPath(rootDir: string, sinceCommit?: string | null): boolean {
1756 const head = getGitHeadSha(rootDir);
1757 if (head == null) return true; // no commits (or not a git repo — caller handles that)
1758 if (!sinceCommit) return false;
1759 if (sinceCommit === head) return true;
1760 try {
1761 execFileSync('git', ['cat-file', '-e', `${sinceCommit}^{commit}`], {
1762 cwd: rootDir, encoding: 'utf-8', timeout: 5000, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true,
1763 });
1764 return true;
1765 } catch {
1766 return false;
1767 }
1768}
1769
1770/**
1771 * `repoPrefix` is where `repoDir` sits in its repository ({@link gitRepoPrefix}):

Callers 1

getChangedFilesMethod · 0.85

Calls 1

getGitHeadShaFunction · 0.85

Tested by

no test coverage detected