MCPcopy Index your code
hub / github.com/cli/cli / pullRequestStatus

Function pullRequestStatus

pkg/cmd/pr/status/http.go:32–187  ·  view source on GitHub ↗
(httpClient *http.Client, repo ghrepo.Interface, options requestOptions)

Source from the content-addressed store, hash-verified

30}
31
32func pullRequestStatus(httpClient *http.Client, repo ghrepo.Interface, options requestOptions) (*pullRequestsPayload, error) {
33 apiClient := api.NewClientFromHTTP(httpClient)
34 type edges struct {
35 TotalCount int
36 Edges []struct {
37 Node api.PullRequest
38 }
39 }
40
41 type response struct {
42 Repository struct {
43 DefaultBranchRef struct {
44 Name string
45 }
46 PullRequests edges
47 PullRequest *api.PullRequest
48 }
49 ViewerCreated edges
50 ReviewRequested edges
51 }
52
53 var fragments string
54 if len(options.Fields) > 0 {
55 fields := set.NewStringSet()
56 fields.AddValues(options.Fields)
57 // these are always necessary to find the PR for the current branch
58 fields.AddValues([]string{"isCrossRepository", "headRepositoryOwner", "headRefName"})
59 gr := api.PullRequestGraphQL(fields.ToSlice())
60 fragments = fmt.Sprintf("fragment pr on PullRequest{%s}fragment prWithReviews on PullRequest{...pr}", gr)
61 } else {
62 var err error
63 fragments, err = pullRequestFragment(options.ConflictStatus, options.CheckRunAndStatusContextCountsSupported)
64 if err != nil {
65 return nil, err
66 }
67 }
68
69 queryPrefix := `
70 query PullRequestStatus($owner: String!, $repo: String!, $headRefName: String!, $viewerQuery: String!, $reviewerQuery: String!, $per_page: Int = 10) {
71 repository(owner: $owner, name: $repo) {
72 defaultBranchRef {
73 name
74 }
75 pullRequests(headRefName: $headRefName, first: $per_page, orderBy: { field: CREATED_AT, direction: DESC }) {
76 totalCount
77 edges {
78 node {
79 ...prWithReviews
80 }
81 }
82 }
83 }
84 `
85 if options.CurrentPR > 0 {
86 queryPrefix = `
87 query PullRequestStatus($owner: String!, $repo: String!, $number: Int!, $viewerQuery: String!, $reviewerQuery: String!, $per_page: Int = 10) {
88 repository(owner: $owner, name: $repo) {
89 defaultBranchRef {

Callers 1

statusRunFunction · 0.85

Calls 13

NewClientFromHTTPFunction · 0.92
NewStringSetFunction · 0.92
PullRequestGraphQLFunction · 0.92
FullNameFunction · 0.92
pullRequestFragmentFunction · 0.85
getCurrentUsernameFunction · 0.85
AddValuesMethod · 0.80
GraphQLMethod · 0.80
HeadLabelMethod · 0.80
ToSliceMethod · 0.65
RepoHostMethod · 0.65
RepoOwnerMethod · 0.65

Tested by

no test coverage detected