MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / parseShorthandSource

Function parseShorthandSource

internal/metadata/catalog.go:269–288  ·  view source on GitHub ↗

parseShorthandSource handles "owner/repo" and "owner/repo@branch" forms.

(s string)

Source from the content-addressed store, hash-verified

267
268// parseShorthandSource handles "owner/repo" and "owner/repo@branch" forms.
269func parseShorthandSource(s string) (owner, repo, branch, path string, ok bool) {
270 if at := strings.Index(s, "@"); at >= 0 {
271 branch = s[at+1:]
272 s = s[:at]
273 }
274 parts := strings.Split(s, "/")
275 if len(parts) < 2 || parts[0] == "" || parts[1] == "" {
276 return "", "", "", "", false
277 }
278 // A GitHub owner/repo has no dots; if the first segment looks like a
279 // hostname (e.g. "example.com/a"), this isn't a GitHub source.
280 if strings.Contains(parts[0], ".") {
281 return "", "", "", "", false
282 }
283 owner, repo = parts[0], parts[1]
284 if len(parts) > 2 {
285 path = strings.Join(parts[2:], "/")
286 }
287 return owner, repo, branch, path, true
288}

Callers 1

parseGithubSourceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected