MCPcopy
hub / github.com/garrytan/gstack / getRemoteSlug

Function getRemoteSlug

browse/src/config.ts:124–142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

122 * Falls back to the directory basename if no remote is configured.
123 */
124export 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.

Callers 1

config.test.tsFile · 0.90

Calls 1

getGitRootFunction · 0.70

Tested by

no test coverage detected