(client *http.Client, repo ghrepo.Interface)
| 10 | ) |
| 11 | |
| 12 | func deleteRepo(client *http.Client, repo ghrepo.Interface) error { |
| 13 | oldClient := *client |
| 14 | client = &oldClient |
| 15 | client.CheckRedirect = func(req *http.Request, via []*http.Request) error { |
| 16 | return http.ErrUseLastResponse |
| 17 | } |
| 18 | |
| 19 | url, err := safeurl.JoinPathWithHostPrefix(ghinstance.RESTPrefix(repo.RepoHost()), "repos", repo.RepoOwner(), repo.RepoName()) |
| 20 | if err != nil { |
| 21 | return err |
| 22 | } |
| 23 | |
| 24 | request, err := http.NewRequest("DELETE", url.String(), nil) |
| 25 | if err != nil { |
| 26 | return err |
| 27 | } |
| 28 | |
| 29 | resp, err := client.Do(request) |
| 30 | if err != nil { |
| 31 | return err |
| 32 | } |
| 33 | defer resp.Body.Close() |
| 34 | |
| 35 | if resp.StatusCode > 299 { |
| 36 | api.EndpointNeedsScopes(resp, "delete_repo") |
| 37 | return api.HandleHTTPError(resp) |
| 38 | } |
| 39 | |
| 40 | return nil |
| 41 | } |
no test coverage detected