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.
|
All three review items are addressed in signed commit |
| type PullRequestStackDetails struct { | ||
| // ID is the ID of the stack. | ||
| ID *int64 `json:"id,omitempty"` | ||
| // 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"` | ||
| // Base is the branch the entire stack ultimately targets. | ||
| Base *PullRequestStackBase `json:"base"` | ||
| // 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.
| type PullRequestStackDetails struct { | |
| // ID is the ID of the stack. | |
| ID *int64 `json:"id,omitempty"` | |
| // 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"` | |
| // Base is the branch the entire stack ultimately targets. | |
| Base *PullRequestStackBase `json:"base"` | |
| // 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"` | |
| } | |
| type PullRequestStackDetails struct { | |
| // ID is the ID of the stack. | |
| ID int64 `json:"id"` | |
| // Number is the number of the stack. | |
| Number int `json:"number"` | |
| // NodeID is the global node ID of the stack. | |
| NodeID string `json:"node_id"` | |
| // URL is the API URL of the stack. | |
| URL string `json:"url"` | |
| // Base is the branch the entire stack ultimately targets. | |
| Base *PullRequestStackBase `json:"base"` | |
| // Open reports whether the stack contains any open pull requests. | |
| Open bool `json:"open"` | |
| // CreatedAt is the time the stack was created. | |
| CreatedAt Timestamp `json:"created_at"` | |
| // PullRequests contains the pull requests in the stack, from bottom to top. | |
| PullRequests []*PullRequest `json:"pull_requests"` | |
| } |
All fields are required according to response schema and we don't use ,omitempty with required field CONTRIBUTING.md
"title": "Pull Request Stack Minimal",
"type": "object",
"required": [
"id",
"number",
"node_id",
"url",
"base",
"open",
"created_at",
"pull_requests"
],| // URL is the API URL of the stack. | ||
| URL *string `json:"url,omitempty"` | ||
| // Base is the branch the entire stack ultimately targets. | ||
| Base *PullRequestStackBase `json:"base"` |
There was a problem hiding this comment.
PullRequestStackBase has one extra field sha which is not present in response schema. so let's implement a new struct instead.
// PullRequestStackBase represents the base of a stacked pull request's stack:
// the branch the entire stack ultimately targets.
type PullRequestStackBase struct {
Ref string `json:"ref"`
SHA string `json:"sha"`
}response schema
"base": {
"type": "object",
"required": [
"ref"
],
"properties": {
"ref": {
"type": "string"
}
}
}| // GitHub API docs: https://docs.github.com/rest/pulls/stacks?apiVersion=2022-11-28#list-pull-request-stacks | ||
| // | ||
| //meta:operation GET /repos/{owner}/{repo}/stacks | ||
| func (s *PullRequestsService) ListStacks(ctx context.Context, owner, repo string, opts *PullRequestListStacksOptions) ([]*PullRequestStackDetails, *Response, error) { |
There was a problem hiding this comment.
Response schema of List pull request stacks and Create a pull request stack ... differ slightly.
pull_requests object in the List pull request stacks response contains fewer fields than the response from the other endpoint. So we can't use []*PullRequestStackDetails here.
|
Thanks, both differences check out against the OpenAPI description. Pushed 5ad53ca.
On the list endpoint: the difference is in Also dropped |
Not-Dhananjay-Mishra
left a comment
There was a problem hiding this comment.
A few struct name suggestions.
| } | ||
|
|
||
| // CreatePullRequestStackRequest represents a request to create a pull request stack. | ||
| type CreatePullRequestStackRequest struct { |
There was a problem hiding this comment.
| type CreatePullRequestStackRequest struct { | |
| type PullRequestCreateStackRequest struct { |
I believe this would be better name
| } | ||
|
|
||
| // AddPullRequestsToStackRequest represents a request to append pull requests to a stack. | ||
| type AddPullRequestsToStackRequest struct { |
There was a problem hiding this comment.
| type AddPullRequestsToStackRequest struct { | |
| type PullRequestsAddToStackRequest struct { |
|
|
||
| // PullRequestStackPullRequest represents a pull request in a stack returned by | ||
| // PullRequestsService.CreateStack, GetStack, AddToStack, and Unstack. | ||
| type PullRequestStackPullRequest struct { |
There was a problem hiding this comment.
How is StackPullRequest? PullRequestStackPullRequest feels repetitive.
| type PullRequestStackPullRequest struct { | |
| type StackPullRequest struct { |
|
|
||
| // PullRequestStackMinimalPullRequest represents a pull request in a stack | ||
| // returned by PullRequestsService.ListStacks. | ||
| type PullRequestStackMinimalPullRequest struct { |
There was a problem hiding this comment.
How is StackMinimalPullRequest? PullRequestStackMinimalPullRequest feels repetitive.
| type PullRequestStackMinimalPullRequest struct { | |
| type StackMinimalPullRequest struct { |
|
|
||
| // PullRequestStackMinimalBranch represents the head branch of a pull request | ||
| // returned by PullRequestsService.ListStacks. | ||
| type PullRequestStackMinimalBranch struct { |
There was a problem hiding this comment.
| type PullRequestStackMinimalBranch struct { | |
| type PullRequestStackHead struct { |
Fixes #4435
Add typed
PullRequestsServicesupport for GitHub's five stacked pull requestREST endpoints:
The change keeps pull-request membership metadata separate from the endpoint
stack resource, adds typed request and list-option types, handles both
updated-stack and
204 No Contentunstack responses, and regenerates accessorsand 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.