MCPcopy Index your code
hub / github.com/cursor/cookbook / detectCloudRepository

Function detectCloudRepository

sdk/coding-agent-cli/src/agent.ts:392–409  ·  view source on GitHub ↗
(cwd: string)

Source from the content-addressed store, hash-verified

390}
391
392function detectCloudRepository(cwd: string): CloudRepository {
393 const remote = runGit(cwd, ["config", "--get", "remote.origin.url"])
394
395 if (!remote) {
396 throw new Error("Cloud mode requires a git repository with remote.origin.url set.")
397 }
398
399 const url = normalizeGitHubRemote(remote)
400
401 if (!url) {
402 throw new Error("Cloud mode currently expects remote.origin.url to point at GitHub.")
403 }
404
405 const branch = runGit(cwd, ["rev-parse", "--abbrev-ref", "HEAD"])
406 const startingRef = branch && branch !== "HEAD" ? branch : undefined
407
408 return startingRef ? { url, startingRef } : { url }
409}
410
411function runGit(cwd: string, args: string[]) {
412 try {

Callers 2

executionTargetMethod · 0.85
createAgentMethod · 0.85

Calls 2

runGitFunction · 0.85
normalizeGitHubRemoteFunction · 0.85

Tested by

no test coverage detected