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

Function fetchRefToRefspec

pkg/workflow/checkout_step_generator.go:614–626  ·  view source on GitHub ↗

fetchRefToRefspec converts a user-facing fetch pattern to a git refspec. Special values: - "*" → "+refs/heads/*:refs/remotes/origin/*" - "refs/pulls/open/*" → "+refs/pull/*/head:refs/remotes/origin/pull/*/head" All other values are treated as branch names or glob patterns and mapped to

(pattern string)

Source from the content-addressed store, hash-verified

612// All other values are treated as branch names or glob patterns and mapped to
613// the canonical remote-tracking refspec form.
614func fetchRefToRefspec(pattern string) string {
615 switch pattern {
616 case "*":
617 checkoutManagerLog.Print("Fetch refspec: wildcard expanded to all branches")
618 return "+refs/heads/*:refs/remotes/origin/*"
619 case "refs/pulls/open/*":
620 checkoutManagerLog.Print("Fetch refspec: open PRs pattern expanded")
621 return "+refs/pull/*/head:refs/remotes/origin/pull/*/head"
622 default:
623 // Treat as branch name or glob: map to remote tracking ref
624 return fmt.Sprintf("+refs/heads/%s:refs/remotes/origin/%s", pattern, pattern)
625 }
626}
627
628// generateFetchStepLines generates a "Fetch additional refs" YAML step for the given checkout
629// entry when it has fetch refs configured. Returns an empty string when there are no fetch refs.

Callers 2

generateFetchStepLinesFunction · 0.85
TestFetchRefToRefspecFunction · 0.85

Calls 1

PrintMethod · 0.80

Tested by 1

TestFetchRefToRefspecFunction · 0.68