Skip to content

Commit b633a8b

Browse files
committed
refactor(scout): fold github remote parsing into repository
1 parent c750df3 commit b633a8b

3 files changed

Lines changed: 10 additions & 35 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { AppRuntime } from "@/effect/app-runtime"
3333
import { Git } from "@/git"
3434
import { setTimeout as sleep } from "node:timers/promises"
3535
import { Process } from "@/util"
36-
import { parseGitHubRemote } from "@/util/github-remote"
36+
import { parseGitHubRemote } from "@/util/repository"
3737
import { Effect } from "effect"
3838

3939
type GitHubAuthor = {

packages/opencode/src/util/github-remote.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

packages/opencode/src/util/repository.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ export function parseRepositoryReference(input: string) {
8888
}
8989
}
9090

91+
export function parseGitHubRemote(input: string) {
92+
const cleaned = normalize(input)
93+
if (!cleaned.includes("://") && !cleaned.match(/^(?:[^@/\s]+@)?github\.com:/)) return null
94+
95+
const parsed = parseRepositoryReference(cleaned)
96+
if (!parsed || parsed.host !== "github.com" || !parsed.owner || parsed.segments.length !== 2) return null
97+
return { owner: parsed.owner, repo: parsed.repo }
98+
}
99+
91100
export function repositoryCachePath(input: Reference) {
92101
return path.join(Global.Path.repos, ...input.host.split(":"), ...input.segments)
93102
}

0 commit comments

Comments
 (0)