From 99577a89d661d17eb7a8fb2900909f499e5cbe38 Mon Sep 17 00:00:00 2001 From: Waridley Date: Tue, 5 May 2026 21:04:46 -0500 Subject: [PATCH] fix: Accept any github remote name when parsing url Instead of checking only `origin`, this fix searches all remotes for one that successfully parses as a Github URL. --- packages/opencode/src/cli/cmd/github.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/opencode/src/cli/cmd/github.ts b/packages/opencode/src/cli/cmd/github.ts index ea5b35ef7868..bac33efb4477 100644 --- a/packages/opencode/src/cli/cmd/github.ts +++ b/packages/opencode/src/cli/cmd/github.ts @@ -261,13 +261,21 @@ export const GithubInstallCommand = effectCmd({ throw new UI.CancelledError() } - // Get repo info - const info = await Effect.runPromise(gitSvc.run(["remote", "get-url", "origin"], { cwd: ctx.worktree })).then( + // Get repo info - parse all remotes to find a GitHub one + const info = await Effect.runPromise(gitSvc.run(["remote", "-v"], { cwd: ctx.worktree })).then( (x) => x.text().trim(), ) - const parsed = parseGitHubRemote(info) + // get the second column of the output of `git remote -v` to get all remote URL's + const urls = info + .split("\n") + .map((line) => line.split(/\s+/)[1]) + .filter(Boolean) + // Find the first valid GitHub remote URL + const parsed = urls.map(parseGitHubRemote).find((p): p is { owner: string; repo: string } => p !== null) if (!parsed) { - prompts.log.error(`Could not find git repository. Please run this command from a git repository.`) + prompts.log.error( + `Could not find GitHub remote. Please run this command from a repository with a valid GitHub remote configured.`, + ) throw new UI.CancelledError() } return { owner: parsed.owner, repo: parsed.repo, root: ctx.worktree }