(httpClient *http.Client, repo ghrepo.Interface)
| 14 | ) |
| 15 | |
| 16 | func repoExists(httpClient *http.Client, repo ghrepo.Interface) (bool, error) { |
| 17 | url := fmt.Sprintf("%srepos/%s/%s", ghinstance.RESTPrefix(repo.RepoHost()), repo.RepoOwner(), repo.RepoName()) |
| 18 | req, err := http.NewRequest("GET", url, nil) |
| 19 | if err != nil { |
| 20 | return false, err |
| 21 | } |
| 22 | |
| 23 | resp, err := httpClient.Do(req) |
| 24 | if err != nil { |
| 25 | return false, err |
| 26 | } |
| 27 | defer resp.Body.Close() |
| 28 | |
| 29 | switch resp.StatusCode { |
| 30 | case 200: |
| 31 | return true, nil |
| 32 | case 404: |
| 33 | return false, nil |
| 34 | default: |
| 35 | return false, api.HandleHTTPError(resp) |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | func hasScript(httpClient *http.Client, repo ghrepo.Interface) (bool, error) { |
| 40 | path := fmt.Sprintf("repos/%s/%s/contents/%s", |
no test coverage detected