MCPcopy Index your code
hub / github.com/cli/cli / ResolveRef

Function ResolveRef

internal/skills/discovery/discovery.go:203–221  ·  view source on GitHub ↗

ResolveRef determines the git ref to use for a given owner/repo. Priority: explicit version > latest release tag > default branch.

(client *api.Client, host, owner, repo, version string)

Source from the content-addressed store, hash-verified

201// ResolveRef determines the git ref to use for a given owner/repo.
202// Priority: explicit version > latest release tag > default branch.
203func ResolveRef(client *api.Client, host, owner, repo, version string) (*ResolvedRef, error) {
204 if version != "" {
205 return resolveExplicitRef(client, host, owner, repo, version)
206 }
207 ref, err := resolveLatestRelease(client, host, owner, repo)
208 if err == nil {
209 return ref, nil
210 }
211 // Only fall back to the default branch when the repository genuinely
212 // has no releases (404) or the latest release has no tag. Any other
213 // API error (403, 500, network failure, …) is surfaced immediately
214 // so it cannot silently mask problems and cause an unexpected ref to
215 // be used.
216 var nre *noReleasesError
217 if !errors.As(err, &nre) {
218 return nil, err
219 }
220 return resolveDefaultBranch(client, host, owner, repo)
221}
222
223// resolveExplicitRef resolves a user-supplied version string. It supports:
224// - fully qualified refs: "refs/tags/v1.0" or "refs/heads/main"

Callers 4

updateRunFunction · 0.92
resolveVersionFunction · 0.92
previewRunFunction · 0.92
TestResolveRefFunction · 0.85

Calls 3

resolveExplicitRefFunction · 0.85
resolveLatestReleaseFunction · 0.85
resolveDefaultBranchFunction · 0.85

Tested by 1

TestResolveRefFunction · 0.68