feat: Add stacked pull request endpoints - #4436
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4436 +/- ##
=======================================
Coverage 97.55% 97.56%
=======================================
Files 194 195 +1
Lines 19892 19962 +70
=======================================
+ Hits 19406 19476 +70
Misses 268 268
Partials 218 218 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
gmlewis
left a comment
There was a problem hiding this comment.
Thank you, @Bortlesboat!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
| @@ -136,10 +136,20 @@ type PullRequestStack struct { | |||
| // Position is the one-based position of this pull request within the stack, | |||
| // where 1 is the bottom of the stack. | |||
| Position *int `json:"position,omitempty"` | |||
| // ID is the ID of the stack that this pull request belongs to. | |||
| // ID is the ID of the stack. | |||
| ID *int64 `json:"id,omitempty"` | |||
| // Number is the number of the stack that this pull request belongs to. | |||
| // Number is the number of the stack. | |||
| Number *int `json:"number,omitempty"` | |||
| // NodeID is the global node ID of the stack. | |||
| NodeID *string `json:"node_id,omitempty"` | |||
| // URL is the API URL of the stack. | |||
| URL *string `json:"url,omitempty"` | |||
| // Open reports whether the stack contains any open pull requests. | |||
| Open *bool `json:"open,omitempty"` | |||
| // CreatedAt is the time the stack was created. | |||
| CreatedAt *Timestamp `json:"created_at,omitempty"` | |||
| // PullRequests contains the pull requests in the stack, from bottom to top. | |||
| PullRequests []*PullRequest `json:"pull_requests,omitempty"` | |||
There was a problem hiding this comment.
// PullRequest represents a GitHub pull request on a repository.
type PullRequest struct {
ID *int64 `json:"id,omitempty"`
Number *int `json:"number,omitempty"`
...
Head *PullRequestBranch `json:"head,omitempty"`
Base *PullRequestBranch `json:"base,omitempty"`
Stack *PullRequestStack `json:"stack,omitempty"`
}PullRequestStack used with PullRequest struct, but the schema ofPullRequest.Stack(docs) differs from the schema used by the stacked pull request endpoints. I think we should introduce a new struct instead of reusing PullRequestStack.
| func TestPullRequestStack_unmarshal(t *testing.T) { | ||
| t.Parallel() | ||
| testJSONUnmarshalOnly(t, testPullRequestStack(), testPullRequestStackResponse()) | ||
| } | ||
|
|
||
| func TestCreatePullRequestStackRequest_marshal(t *testing.T) { | ||
| t.Parallel() | ||
| testJSONMarshal(t, &CreatePullRequestStackRequest{PullRequests: []int{101, 102}}, `{"pull_requests":[101,102]}`) | ||
| } | ||
|
|
||
| func TestAddPullRequestsToStackRequest_marshal(t *testing.T) { | ||
| t.Parallel() | ||
| testJSONMarshal(t, &AddPullRequestsToStackRequest{PullRequests: []int{103}}, `{"pull_requests":[103]}`) | ||
| } |
There was a problem hiding this comment.
These test can be removed, because we only write _marshal/_unmarshal tests for structs that implement custom Marshal/Unmarshal methods.
| "page": "2", | ||
| "per_page": "50", | ||
| }) | ||
| fmt.Fprintf(w, "[%s]", testPullRequestStackResponse()) |
There was a problem hiding this comment.
| fmt.Fprintf(w, "[%s]", testPullRequestStackResponse()) | |
| fmt.Fprintf(w, "[%v]", testPullRequestStackResponse()) |
Fixes #4435
Add typed
PullRequestsServicesupport for GitHub's five stacked pull requestREST endpoints:
The change extends the existing
PullRequestStackrepresentation, adds therequest and list-option types, handles both updated-stack and
204 No Contentunstack responses, and regenerates accessors and iterators. Request methods,
paths, query parameters, bodies, response decoding, and failure paths have
focused coverage.
API contract: https://docs.github.com/en/rest/pulls/stacks?apiVersion=2022-11-28
Validation:
script/fmt.shscript/lint.shacross all 12 modulesscript/test.sh -covermode atomic ./...across all 12 modulesgit diff --checkThe local Go configuration has CGO disabled, so a race build was not available;
the full non-race suite passed.
AI assistance: OpenAI Codex helped draft the API bindings, tests, generated-file
workflow, and PR description. I reviewed the rendered diff and validation
evidence, understand every submitted line, and take responsibility for the
contribution and review follow-up.