MCPcopy
hub / github.com/cli/cli / RepoExists

Function RepoExists

api/queries_repo.go:1668–1686  ·  view source on GitHub ↗
(client *Client, repo ghrepo.Interface)

Source from the content-addressed store, hash-verified

1666}
1667
1668func RepoExists(client *Client, repo ghrepo.Interface) (bool, error) {
1669 path := fmt.Sprintf("%srepos/%s/%s", ghinstance.RESTPrefix(repo.RepoHost()), repo.RepoOwner(), repo.RepoName())
1670
1671 resp, err := client.HTTP().Head(path)
1672 if err != nil {
1673 return false, err
1674 }
1675
1676 defer resp.Body.Close()
1677
1678 switch resp.StatusCode {
1679 case 200:
1680 return true, nil
1681 case 404:
1682 return false, nil
1683 default:
1684 return false, ghAPI.HandleHTTPError(resp)
1685 }
1686}
1687
1688// RepoLicenses fetches available repository licenses.
1689// It uses API v3 because licenses are not supported by GraphQL.

Callers 2

runBrowseFunction · 0.92
TestRepoExistsFunction · 0.85

Calls 6

RESTPrefixFunction · 0.92
HTTPMethod · 0.80
RepoHostMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
CloseMethod · 0.65

Tested by 1

TestRepoExistsFunction · 0.68