(cwd: string)
| 390 | } |
| 391 | |
| 392 | function 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 | |
| 411 | function runGit(cwd: string, args: string[]) { |
| 412 | try { |
no test coverage detected