MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getRemoteUrlForDir

Function getRemoteUrlForDir

source code/utils/git/gitFilesystem.ts:647–662  ·  view source on GitHub ↗
(cwd: string)

Source from the content-addressed store, hash-verified

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