()
| 122 | * Falls back to the directory basename if no remote is configured. |
| 123 | */ |
| 124 | export function getRemoteSlug(): string { |
| 125 | try { |
| 126 | const proc = Bun.spawnSync(['git', 'remote', 'get-url', 'origin'], { |
| 127 | stdout: 'pipe', |
| 128 | stderr: 'pipe', |
| 129 | timeout: 2_000, |
| 130 | }); |
| 131 | if (proc.exitCode !== 0) throw new Error('no remote'); |
| 132 | const url = proc.stdout.toString().trim(); |
| 133 | // SSH: git@github.com:owner/repo.git → owner-repo |
| 134 | // HTTPS: https://github.com/owner/repo.git → owner-repo |
| 135 | const match = url.match(/[:/]([^/]+)\/([^/]+?)(?:\.git)?$/); |
| 136 | if (match) return `${match[1]}-${match[2]}`; |
| 137 | throw new Error('unparseable'); |
| 138 | } catch { |
| 139 | const root = getGitRoot(); |
| 140 | return path.basename(root || process.cwd()); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * Read the binary version (git SHA) from browse/dist/.version. |
no test coverage detected