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

Function RepoExists

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

Source from the content-addressed store, hash-verified

1671}
1672
1673func RepoExists(client *Client, repo ghrepo.Interface) (bool, error) {
1674 u, err := safeurl.JoinPathWithHostPrefix(ghinstance.RESTPrefix(repo.RepoHost()), "repos", repo.RepoOwner(), repo.RepoName())
1675 if err != nil {
1676 return false, err
1677 }
1678
1679 resp, err := client.HTTP().Head(u.String())
1680 if err != nil {
1681 return false, err
1682 }
1683
1684 defer resp.Body.Close()
1685
1686 switch resp.StatusCode {
1687 case 200:
1688 return true, nil
1689 case 404:
1690 return false, nil
1691 default:
1692 return false, ghAPI.HandleHTTPError(resp)
1693 }
1694}
1695
1696// RepoLicenses fetches available repository licenses.
1697// 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