GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: github install cmd if repo has . in it · jkoelker/opencode@3ac42e9

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .opencode
    • bun.lock
    • package.json
  • packages/opencode
    • src/cli/cmd
      • github.ts
    • test/cli
      • github-remote.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.opencode/bun.lock‎

Copy file name to clipboardExpand all lines: .opencode/bun.lock
+3-3Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎.opencode/package.json‎

Copy file name to clipboard
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dependencies": {
33
"@octokit/rest": "^22.0.1",
4-
"@opencode-ai/plugin": "0.0.0-dev-202512161535"
4+
"@opencode-ai/plugin": "0.0.0-dev-202512161610"
55
}
66
}
Collapse file

‎packages/opencode/src/cli/cmd/github.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/github.ts
+15-10Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,19 @@ const AGENT_USERNAME = "opencode-agent[bot]"
128128
const AGENT_REACTION = "eyes"
129129
const WORKFLOW_FILE = ".github/workflows/opencode.yml"
130130

131+
// Parses GitHub remote URLs in various formats:
132+
// - https://github.com/owner/repo.git
133+
// - https://github.com/owner/repo
134+
// - [email protected]:owner/repo.git
135+
// - [email protected]:owner/repo
136+
// - ssh://[email protected]/owner/repo.git
137+
// - ssh://[email protected]/owner/repo
138+
export function parseGitHubRemote(url: string): { owner: string; repo: string } | null {
139+
const match = url.match(/^(?:(?:https?|ssh):\/\/)?(?:git@)?github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?$/)
140+
if (!match) return null
141+
return { owner: match[1], repo: match[2] }
142+
}
143+
131144
export const GithubCommand = cmd({
132145
command: "github",
133146
describe: "manage GitHub agent",
@@ -197,20 +210,12 @@ export const GithubInstallCommand = cmd({
197210

198211
// Get repo info
199212
const info = (await $`git remote get-url origin`.quiet().nothrow().text()).trim()
200-
// match https or git pattern
201-
// ie. https://github.com/sst/opencode.git
202-
// ie. https://github.com/sst/opencode
203-
// ie. git@github.com:sst/opencode.git
204-
// ie. git@github.com:sst/opencode
205-
// ie. ssh://git@github.com/sst/opencode.git
206-
// ie. ssh://git@github.com/sst/opencode
207-
const parsed = info.match(/^(?:(?:https?|ssh):\/\/)?(?:git@)?github\.com[:/]([^/]+)\/([^/.]+?)(?:\.git)?$/)
213+
const parsed = parseGitHubRemote(info)
208214
if (!parsed) {
209215
prompts.log.error(`Could not find git repository. Please run this command from a git repository.`)
210216
throw new UI.CancelledError()
211217
}
212-
const [, owner, repo] = parsed
213-
return { owner, repo, root: Instance.worktree }
218+
return { owner: parsed.owner, repo: parsed.repo, root: Instance.worktree }
214219
}
215220

216221
async function promptProvider() {
Collapse file

‎packages/opencode/test/cli/github-remote.test.ts‎

Copy file name to clipboard
+80Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { test, expect } from "bun:test"
2+
import { parseGitHubRemote } from "../../src/cli/cmd/github"
3+
4+
test("parses https URL with .git suffix", () => {
5+
expect(parseGitHubRemote("https://github.com/sst/opencode.git")).toEqual({ owner: "sst", repo: "opencode" })
6+
})
7+
8+
test("parses https URL without .git suffix", () => {
9+
expect(parseGitHubRemote("https://github.com/sst/opencode")).toEqual({ owner: "sst", repo: "opencode" })
10+
})
11+
12+
test("parses git@ URL with .git suffix", () => {
13+
expect(parseGitHubRemote("[email protected]:sst/opencode.git")).toEqual({ owner: "sst", repo: "opencode" })
14+
})
15+
16+
test("parses git@ URL without .git suffix", () => {
17+
expect(parseGitHubRemote("[email protected]:sst/opencode")).toEqual({ owner: "sst", repo: "opencode" })
18+
})
19+
20+
test("parses ssh:// URL with .git suffix", () => {
21+
expect(parseGitHubRemote("ssh://[email protected]/sst/opencode.git")).toEqual({ owner: "sst", repo: "opencode" })
22+
})
23+
24+
test("parses ssh:// URL without .git suffix", () => {
25+
expect(parseGitHubRemote("ssh://[email protected]/sst/opencode")).toEqual({ owner: "sst", repo: "opencode" })
26+
})
27+
28+
test("parses http URL", () => {
29+
expect(parseGitHubRemote("http://github.com/owner/repo")).toEqual({ owner: "owner", repo: "repo" })
30+
})
31+
32+
test("parses URL with hyphenated owner and repo names", () => {
33+
expect(parseGitHubRemote("https://github.com/my-org/my-repo.git")).toEqual({ owner: "my-org", repo: "my-repo" })
34+
})
35+
36+
test("parses URL with underscores in names", () => {
37+
expect(parseGitHubRemote("[email protected]:my_org/my_repo.git")).toEqual({ owner: "my_org", repo: "my_repo" })
38+
})
39+
40+
test("parses URL with numbers in names", () => {
41+
expect(parseGitHubRemote("https://github.com/org123/repo456")).toEqual({ owner: "org123", repo: "repo456" })
42+
})
43+
44+
test("parses repos with dots in the name", () => {
45+
expect(parseGitHubRemote("https://github.com/socketio/socket.io.git")).toEqual({
46+
owner: "socketio",
47+
repo: "socket.io",
48+
})
49+
expect(parseGitHubRemote("https://github.com/vuejs/vue.js")).toEqual({
50+
owner: "vuejs",
51+
repo: "vue.js",
52+
})
53+
expect(parseGitHubRemote("[email protected]:mrdoob/three.js.git")).toEqual({
54+
owner: "mrdoob",
55+
repo: "three.js",
56+
})
57+
expect(parseGitHubRemote("https://github.com/jashkenas/backbone.git")).toEqual({
58+
owner: "jashkenas",
59+
repo: "backbone",
60+
})
61+
})
62+
63+
test("returns null for non-github URLs", () => {
64+
expect(parseGitHubRemote("https://gitlab.com/owner/repo.git")).toBeNull()
65+
expect(parseGitHubRemote("[email protected]:owner/repo.git")).toBeNull()
66+
expect(parseGitHubRemote("https://bitbucket.org/owner/repo")).toBeNull()
67+
})
68+
69+
test("returns null for invalid URLs", () => {
70+
expect(parseGitHubRemote("not-a-url")).toBeNull()
71+
expect(parseGitHubRemote("")).toBeNull()
72+
expect(parseGitHubRemote("github.com")).toBeNull()
73+
expect(parseGitHubRemote("https://github.com/")).toBeNull()
74+
expect(parseGitHubRemote("https://github.com/owner")).toBeNull()
75+
})
76+
77+
test("returns null for URLs with extra path segments", () => {
78+
expect(parseGitHubRemote("https://github.com/owner/repo/tree/main")).toBeNull()
79+
expect(parseGitHubRemote("https://github.com/owner/repo/blob/main/file.ts")).toBeNull()
80+
})

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.