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

Function deleteRepo

pkg/cmd/repo/delete/http.go:11–33  ·  view source on GitHub ↗
(httpClient *http.Client, repo ghrepo.Interface)

Source from the content-addressed store, hash-verified

9)
10
11func deleteRepo(httpClient *http.Client, repo ghrepo.Interface) error {
12 p, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName())
13 if err != nil {
14 return err
15 }
16
17 // If the repo is renamed (and we're using the old name), the API will return
18 // an HTTP 307 (temporary redirect), which is a METHOD-preserving redirection.
19 // That is, upon receiving a 307, the HTTP client will repeat the same HTTP
20 // method (in this case, DELETE) but against the new location. We don't want
21 // such an implicit behaviour, so we pass the `api.WithoutFollowingRedirects`
22 // to make sure an error is returned.
23 resp, err := api.NewClientFromHTTP(httpClient).Request(repo.RepoHost(), http.MethodDelete, p.String(), nil,
24 api.WithEndpointScopes("delete_repo"),
25 api.WithoutFollowingRedirects(),
26 )
27 if err != nil {
28 return err
29 }
30 defer resp.Body.Close()
31
32 return nil
33}

Callers 4

deleteRunFunction · 0.85
TestDeleteRepoFunction · 0.85

Calls 10

JoinPathFunction · 0.92
NewClientFromHTTPFunction · 0.92
WithEndpointScopesFunction · 0.92
RequestMethod · 0.80
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RepoHostMethod · 0.65
StringMethod · 0.65
CloseMethod · 0.65

Tested by 3

TestDeleteRepoFunction · 0.68