fetchForkInfo uses REST rather than GraphQL so that a missing or moved repository fails with the same error the DELETE would have returned.
(httpClient *http.Client, repo ghrepo.Interface)
| 21 | // fetchForkInfo uses REST rather than GraphQL so that a missing or moved |
| 22 | // repository fails with the same error the DELETE would have returned. |
| 23 | func fetchForkInfo(httpClient *http.Client, repo ghrepo.Interface) (forkInfo, error) { |
| 24 | var info forkInfo |
| 25 | |
| 26 | p, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName()) |
| 27 | if err != nil { |
| 28 | return info, err |
| 29 | } |
| 30 | |
| 31 | // Match the DELETE's scope hint and redirect policy, so that a missing, |
| 32 | // under-scoped, or renamed repository fails here exactly as the DELETE would. |
| 33 | resp, err := api.NewClientFromHTTP(httpClient).Request(repo.RepoHost(), http.MethodGet, p.String(), nil, |
| 34 | api.WithEndpointScopes("delete_repo"), |
| 35 | api.WithoutFollowingRedirects(), |
| 36 | ) |
| 37 | if err != nil { |
| 38 | return info, err |
| 39 | } |
| 40 | defer resp.Body.Close() |
| 41 | |
| 42 | err = json.NewDecoder(resp.Body).Decode(&info) |
| 43 | return info, err |
| 44 | } |
| 45 | |
| 46 | func deleteRepo(httpClient *http.Client, repo ghrepo.Interface) error { |
| 47 | p, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName()) |
no test coverage detected