MCPcopy
hub / github.com/cli/cli / deleteRepo

Function deleteRepo

pkg/cmd/repo/delete/http.go:12–40  ·  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 := fmt.Sprintf("%srepos/%s",
20 ghinstance.RESTPrefix(repo.RepoHost()),
21 ghrepo.FullName(repo))
22
23 request, err := http.NewRequest("DELETE", url, nil)
24 if err != nil {
25 return err
26 }
27
28 resp, err := client.Do(request)
29 if err != nil {
30 return err
31 }
32 defer resp.Body.Close()
33
34 if resp.StatusCode > 299 {
35 api.EndpointNeedsScopes(resp, "delete_repo")
36 return api.HandleHTTPError(resp)
37 }
38
39 return nil
40}

Callers 1

deleteRunFunction · 0.85

Calls 7

RESTPrefixFunction · 0.92
FullNameFunction · 0.92
EndpointNeedsScopesFunction · 0.92
HandleHTTPErrorFunction · 0.92
RepoHostMethod · 0.65
DoMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected