MCPcopy
hub / github.com/codeaashu/claude-code / detectCurrentRepositoryWithHost

Function detectCurrentRepositoryWithHost

src/utils/detectRepository.ts:32–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30 * GitHub host should use this variant.
31 */
32export async function detectCurrentRepositoryWithHost(): Promise<ParsedRepository | null> {
33 const cwd = getCwd()
34
35 if (repositoryWithHostCache.has(cwd)) {
36 return repositoryWithHostCache.get(cwd) ?? null
37 }
38
39 try {
40 const remoteUrl = await getRemoteUrl()
41 logForDebugging(`Git remote URL: ${remoteUrl}`)
42 if (!remoteUrl) {
43 logForDebugging('No git remote URL found')
44 repositoryWithHostCache.set(cwd, null)
45 return null
46 }
47
48 const parsed = parseGitRemote(remoteUrl)
49 logForDebugging(
50 `Parsed repository: ${parsed ? `${parsed.host}/${parsed.owner}/${parsed.name}` : null} from URL: ${remoteUrl}`,
51 )
52 repositoryWithHostCache.set(cwd, parsed)
53 return parsed
54 } catch (error) {
55 logForDebugging(`Error detecting repository: ${error}`)
56 repositoryWithHostCache.set(cwd, null)
57 return null
58 }
59}
60
61/**
62 * Synchronously returns the cached github.com repository for the current cwd

Callers 6

detectCurrentRepositoryFunction · 0.85
teleportToRemoteFunction · 0.85
launchRemoteReviewFunction · 0.85
getPromptForCommandFunction · 0.85

Calls 7

getCwdFunction · 0.85
getRemoteUrlFunction · 0.85
logForDebuggingFunction · 0.85
parseGitRemoteFunction · 0.85
getMethod · 0.65
hasMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected