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

Function visit

src/extraction/index.ts:759–803  ·  view source on GitHub ↗
(repoAbs: string, prefix: string)

Source from the content-addressed store, hash-verified

757 const defaults = defaultsOnlyIgnore();
758 const includeIgnored = loadIncludeIgnoredMatcher(rootDir);
759 const visit = (repoAbs: string, prefix: string): void => {
760 const candidates: string[] = [];
761 try {
762 const o = execFileSync(
763 'git',
764 ['ls-files', '-z', '-o', '--exclude-standard', '--directory'],
765 { cwd: repoAbs, encoding: 'utf-8', timeout: 30000, maxBuffer: 50 * 1024 * 1024, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true }
766 );
767 for (const e of o.split('\0')) {
768 if (e.endsWith('/') && !isWholeCwdEntry(e) && !defaults.ignores(e)) {
769 candidates.push(...findNestedGitRepos(path.join(repoAbs, e), e));
770 }
771 }
772 } catch { /* untracked listing failed — ignored-side discovery still runs */ }
773 // Unexpanded gitlinks (mode 160000) with a real checkout on disk — embedded
774 // repos `git add`ed without `.gitmodules`, or submodules not active here. The
775 // untracked listing above can't see them (they're tracked), so find them the
776 // same way collectGitFiles does, keeping watcher scope == indexer scope.
777 // (#1031, #1033)
778 try {
779 const staged = execFileSync(
780 'git',
781 ['ls-files', '-z', '-s', '--recurse-submodules'],
782 { cwd: repoAbs, encoding: 'utf-8', timeout: 30000, maxBuffer: 50 * 1024 * 1024, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true }
783 );
784 const repoIgnore = buildDefaultIgnore(repoAbs);
785 for (const entry of staged.split('\0')) {
786 if (!entry || entry.slice(0, 6) !== '160000') continue;
787 const tab = entry.indexOf('\t');
788 if (tab === -1) continue;
789 const rel = entry.slice(tab + 1);
790 const relDir = rel.endsWith('/') ? rel : rel + '/';
791 // A gitlink under a gitignored path is respected (not indexed) unless the
792 // project opted it in — same rule as the untracked-ignored kind (#1065).
793 if (gitlinkEmbeddedRepoSkipped(relDir, prefix, defaults, repoIgnore, includeIgnored)) continue;
794 if (classifyGitDir(path.join(repoAbs, rel)) === 'embedded') candidates.push(relDir);
795 }
796 } catch { /* staged listing failed — other discovery still runs */ }
797 candidates.push(...findIgnoredEmbeddedRepos(repoAbs, includeIgnored, prefix));
798 for (const rel of candidates) {
799 const full = normalizePath(prefix + rel);
800 out.push(full);
801 visit(path.join(repoAbs, rel), full);
802 }
803 };
804 visit(rootDir, '');
805 return out;
806}

Callers 1

Calls 9

normalizePathFunction · 0.90
isWholeCwdEntryFunction · 0.85
findNestedGitReposFunction · 0.85
buildDefaultIgnoreFunction · 0.85
classifyGitDirFunction · 0.85
findIgnoredEmbeddedReposFunction · 0.85
ignoresMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected