MCPcopy Index your code
hub / github.com/codeaashu/claude-code / getRemoteUrlForDir

Function getRemoteUrlForDir

src/utils/git/gitFilesystem.ts:645–660  ·  view source on GitHub ↗
(cwd: string)

Source from the content-addressed store, hash-verified

643 * Read the remote origin URL for an arbitrary directory via .git/config.
644 */
645export async function getRemoteUrlForDir(cwd: string): Promise<string | null> {
646 const gitDir = await resolveGitDir(cwd)
647 if (!gitDir) {
648 return null
649 }
650 const url = await parseGitConfigValue(gitDir, 'remote', 'origin', 'url')
651 if (url) {
652 return url
653 }
654 // In worktrees, the config with remote URLs is in the common dir
655 const commonDir = await getCommonDir(gitDir)
656 if (commonDir && commonDir !== gitDir) {
657 return parseGitConfigValue(commonDir, 'remote', 'origin', 'url')
658 }
659 return null
660}
661
662/**
663 * Check if we're in a shallow clone by looking for <commonDir>/shallow.

Callers 2

validateRepoAtPathFunction · 0.85

Calls 3

resolveGitDirFunction · 0.85
parseGitConfigValueFunction · 0.85
getCommonDirFunction · 0.85

Tested by

no test coverage detected