MCPcopy Index your code
hub / github.com/anomalyco/opencode / buildRemoteReference

Function buildRemoteReference

packages/opencode/src/util/repository.ts:105–121  ·  view source on GitHub ↗
(input: { host: string; segments: string[]; remote?: string; protocol?: string })

Source from the content-addressed store, hash-verified

103}
104
105function buildRemoteReference(input: { host: string; segments: string[]; remote?: string; protocol?: string }) {
106 const segments = input.segments.map(trimGitSuffix).filter(Boolean)
107 if (!safeHost(input.host) || !segments.length || segments.some((segment) => !safeSegment(segment))) return null
108 const pathname = segments.join("/")
109 const repo = segments[segments.length - 1]
110 const host = input.host.toLowerCase()
111 return {
112 host,
113 path: pathname,
114 segments,
115 owner: segments.length === 2 ? segments[0] : undefined,
116 repo,
117 remote: input.remote ?? (host === "github.com" ? githubRemote(pathname) : `https://${host}/${pathname}.git`),
118 label: host === "github.com" && segments.length === 2 ? pathname : `${host}/${pathname}`,
119 protocol: input.protocol,
120 } satisfies RemoteReference
121}
122
123function buildFileReference(input: { url: URL; remote: string }) {
124 const filePath = path.normalize(fileURLToPath(input.url))

Callers 1

parseRepositoryReferenceFunction · 0.85

Calls 3

safeHostFunction · 0.70
safeSegmentFunction · 0.70
githubRemoteFunction · 0.70

Tested by

no test coverage detected