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

Function RepoExists

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

Source from the content-addressed store, hash-verified

1675}
1676
1677func RepoExists(client *Client, repo ghrepo.Interface) (bool, error) {
1678 u, err := safeurl.JoinPathWithHostPrefix(ghinstance.RESTPrefix(repo.RepoHost()), "repos", repo.RepoOwner(), repo.RepoName())
1679 if err != nil {
1680 return false, err
1681 }
1682
1683 resp, err := client.HTTP().Head(u.String())
1684 if err != nil {
1685 return false, err
1686 }
1687
1688 defer resp.Body.Close()
1689
1690 switch resp.StatusCode {
1691 case 200:
1692 return true, nil
1693 case 404:
1694 return false, nil
1695 default:
1696 return false, ghAPI.HandleHTTPError(resp)
1697 }
1698}
1699
1700// RepoLicenses fetches available repository licenses.
1701// It uses API v3 because licenses are not supported by GraphQL.

Callers 2

runBrowseFunction · 0.92
TestRepoExistsFunction · 0.85

Calls 8

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

Tested by 1

TestRepoExistsFunction · 0.68