MCPcopy Create free account
hub / github.com/github/gh-aw / parseSourceSpec

Function parseSourceSpec

pkg/cli/spec.go:448–471  ·  view source on GitHub ↗

parseSourceSpec parses a source specification like "owner/repo/path@ref" This is used for parsing the source field from workflow frontmatter

(source string)

Source from the content-addressed store, hash-verified

446// parseSourceSpec parses a source specification like "owner/repo/path@ref"
447// This is used for parsing the source field from workflow frontmatter
448func parseSourceSpec(source string) (*SourceSpec, error) {
449 specLog.Printf("Parsing source spec: %q", source)
450 // Split on @ to separate ref
451 parts := strings.SplitN(source, "@", 2)
452 pathPart := parts[0]
453
454 // Parse path: owner/repo/path/to/workflow.md
455 slashParts := strings.Split(pathPart, "/")
456 if len(slashParts) < 3 {
457 return nil, errors.New("invalid source format: must be owner/repo/path[@ref]")
458 }
459
460 spec := &SourceSpec{
461 Repo: fmt.Sprintf("%s/%s", slashParts[0], slashParts[1]),
462 Path: strings.Join(slashParts[2:], "/"),
463 }
464
465 if len(parts) == 2 {
466 spec.Ref = parts[1]
467 }
468
469 specLog.Printf("Parsed source spec: repo=%s, path=%s, ref=%s", spec.Repo, spec.Path, spec.Ref)
470 return spec, nil
471}
472
473// buildSourceStringWithCommitSHA builds the source string with the actual commit SHA
474// This is used when adding workflows to include the precise commit that was installed

Callers 6

hasLocalModificationsFunction · 0.85
MergeWorkflowContentFunction · 0.85
updateWorkflowFunction · 0.85
previewOrgRepoUpdatesFunction · 0.85

Calls 1

PrintfMethod · 0.45

Tested by 1