| 1666 | } |
| 1667 | |
| 1668 | func 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. |