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

Function findByNumber

pkg/cmd/pr/shared/finder.go:354–382  ·  view source on GitHub ↗
(httpClient *http.Client, repo ghrepo.Interface, number int, fields []string)

Source from the content-addressed store, hash-verified

352}
353
354func findByNumber(httpClient *http.Client, repo ghrepo.Interface, number int, fields []string) (*api.PullRequest, error) {
355 type response struct {
356 Repository struct {
357 PullRequest api.PullRequest
358 }
359 }
360
361 query := fmt.Sprintf(`
362 query PullRequestByNumber($owner: String!, $repo: String!, $pr_number: Int!) {
363 repository(owner: $owner, name: $repo) {
364 pullRequest(number: $pr_number) {%s}
365 }
366 }`, api.PullRequestGraphQL(fields))
367
368 variables := map[string]any{
369 "owner": repo.RepoOwner(),
370 "repo": repo.RepoName(),
371 "pr_number": number,
372 }
373
374 var resp response
375 client := api.NewClientFromHTTP(httpClient)
376 err := client.GraphQL(repo.RepoHost(), query, variables, &resp)
377 if err != nil {
378 return nil, err
379 }
380
381 return &resp.Repository.PullRequest, nil
382}
383
384func findForRefs(httpClient *http.Client, prRefs PRFindRefs, stateFilters, fields []string) (*api.PullRequest, error) {
385 type response struct {

Callers 1

FindMethod · 0.85

Calls 6

PullRequestGraphQLFunction · 0.92
NewClientFromHTTPFunction · 0.92
GraphQLMethod · 0.80
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected