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

Function deleteRepo

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

Source from the content-addressed store, hash-verified

44}
45
46func deleteRepo(httpClient *http.Client, repo ghrepo.Interface) error {
47 p, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName())
48 if err != nil {
49 return err
50 }
51
52 // If the repo is renamed (and we're using the old name), the API will return
53 // an HTTP 307 (temporary redirect), which is a METHOD-preserving redirection.
54 // That is, upon receiving a 307, the HTTP client will repeat the same HTTP
55 // method (in this case, DELETE) but against the new location. We don't want
56 // such an implicit behaviour, so we pass the `api.WithoutFollowingRedirects`
57 // to make sure an error is returned.
58 resp, err := api.NewClientFromHTTP(httpClient).Request(repo.RepoHost(), http.MethodDelete, p.String(), nil,
59 api.WithEndpointScopes("delete_repo"),
60 api.WithoutFollowingRedirects(),
61 )
62 if err != nil {
63 return err
64 }
65 defer resp.Body.Close()
66
67 return nil
68}

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