(cwd: string)
| 643 | * Read the remote origin URL for an arbitrary directory via .git/config. |
| 644 | */ |
| 645 | export 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. |
no test coverage detected