MCPcopy Create free account
hub / github.com/anomalyco/opencode / buildRemote

Function buildRemote

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

Source from the content-addressed store, hash-verified

172}
173
174function buildRemote(input: { host: string; segments: string[]; remote?: string; protocol?: string }) {
175 const segments = input.segments.map(trimGitSuffix).filter(Boolean)
176 if (!safeHost(input.host) || !segments.length || segments.some((segment) => !safeSegment(segment))) return
177 const repositoryPath = segments.join("/")
178 const host = input.host.toLowerCase()
179 return {
180 host,
181 path: repositoryPath,
182 segments,
183 owner: segments.length === 2 ? segments[0] : undefined,
184 repo: segments[segments.length - 1],
185 remote:
186 input.remote ?? (host === "github.com" ? githubRemote(repositoryPath) : `https://${host}/${repositoryPath}.git`),
187 label: host === "github.com" && segments.length === 2 ? repositoryPath : `${host}/${repositoryPath}`,
188 protocol: input.protocol,
189 } satisfies RemoteReference
190}
191
192function buildFile(input: { url: URL; remote: string }) {
193 const filePath = path.normalize(fileURLToPath(input.url))

Callers 1

parseFunction · 0.85

Calls 3

safeHostFunction · 0.70
safeSegmentFunction · 0.70
githubRemoteFunction · 0.70

Tested by

no test coverage detected