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

Function fetchForkInfo

pkg/cmd/repo/delete/http.go:23–44  ·  view source on GitHub ↗

fetchForkInfo uses REST rather than GraphQL so that a missing or moved repository fails with the same error the DELETE would have returned.

(httpClient *http.Client, repo ghrepo.Interface)

Source from the content-addressed store, hash-verified

21// fetchForkInfo uses REST rather than GraphQL so that a missing or moved
22// repository fails with the same error the DELETE would have returned.
23func fetchForkInfo(httpClient *http.Client, repo ghrepo.Interface) (forkInfo, error) {
24 var info forkInfo
25
26 p, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName())
27 if err != nil {
28 return info, err
29 }
30
31 // Match the DELETE's scope hint and redirect policy, so that a missing,
32 // under-scoped, or renamed repository fails here exactly as the DELETE would.
33 resp, err := api.NewClientFromHTTP(httpClient).Request(repo.RepoHost(), http.MethodGet, p.String(), nil,
34 api.WithEndpointScopes("delete_repo"),
35 api.WithoutFollowingRedirects(),
36 )
37 if err != nil {
38 return info, err
39 }
40 defer resp.Body.Close()
41
42 err = json.NewDecoder(resp.Body).Decode(&info)
43 return info, err
44}
45
46func deleteRepo(httpClient *http.Client, repo ghrepo.Interface) error {
47 p, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName())

Callers 1

confirmForkDeletionFunction · 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

no test coverage detected