MCPcopy Create free account
hub / github.com/cli/cli / FetchRepository

Function FetchRepository

internal/skills/discovery/discovery.go:216–233  ·  view source on GitHub ↗

FetchRepository returns the repository's ID and visibility.

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

Source from the content-addressed store, hash-verified

214
215// FetchRepository returns the repository's ID and visibility.
216func FetchRepository(client *api.Client, host, owner, repo string) (*Repository, error) {
217 apiPath, err := safeurl.JoinPath("repos", owner, repo)
218 if err != nil {
219 return nil, err
220 }
221 var resp struct {
222 ID int64 `json:"id"`
223 Visibility string `json:"visibility"`
224 }
225 if err := client.REST(host, "GET", apiPath.String(), nil, &resp); err != nil {
226 return nil, err
227 }
228 if resp.ID == 0 {
229 return nil, fmt.Errorf("could not determine the ID of repository %s/%s", owner, repo)
230 }
231 vis, _ := parseRepoVisibility(resp.Visibility)
232 return &Repository{ID: resp.ID, Visibility: vis}, nil
233}
234
235// ResolveRef determines the git ref to use for a given owner/repo.
236// Priority: explicit version > latest release tag > default branch.

Callers 2

updateRunFunction · 0.92
installRunFunction · 0.92

Calls 5

JoinPathFunction · 0.92
parseRepoVisibilityFunction · 0.85
RESTMethod · 0.65
StringMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected