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

Function deleteRepo

pkg/cmd/repo/delete/http.go:12–41  ·  view source on GitHub ↗
(client *http.Client, repo ghrepo.Interface)

Source from the content-addressed store, hash-verified

10)
11
12func 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}

Callers 1

deleteRunFunction · 0.85

Calls 10

JoinPathWithHostPrefixFunction · 0.92
RESTPrefixFunction · 0.92
EndpointNeedsScopesFunction · 0.92
HandleHTTPErrorFunction · 0.92
RepoHostMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
StringMethod · 0.65
DoMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected