Skip to content

feat: Add stacked pull request endpoints - #4436

Open
Bortlesboat wants to merge 6 commits into
google:masterfrom
Bortlesboat:4435-stacked-pull-requests
Open

feat: Add stacked pull request endpoints#4436
Bortlesboat wants to merge 6 commits into
google:masterfrom
Bortlesboat:4435-stacked-pull-requests

Conversation

@Bortlesboat

@Bortlesboat Bortlesboat commented Aug 6, 2026

Copy link
Copy Markdown

Fixes #4435

Add typed PullRequestsService support for GitHub's five stacked pull request
REST endpoints:

  • list repository stacks, optionally filtered by pull request;
  • create and get a stack;
  • append pull requests to a stack; and
  • unstack the remaining unmerged pull requests.

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 Content unstack 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.sh
  • script/lint.sh across all 11 modules
  • script/test.sh -covermode atomic ./... across all 11 modules
  • git diff --check

The 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.

@gmlewis gmlewis changed the title github: add stacked pull request endpoints feat: Add stacked pull request endpoints Aug 6, 2026
@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Aug 6, 2026
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.54%. Comparing base (3a439fa) to head (fd02503).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4436   +/-   ##
=======================================
  Coverage   98.53%   98.54%           
=======================================
  Files         195      196    +1     
  Lines       17848    17914   +66     
=======================================
+ Hits        17587    17653   +66     
  Misses        261      261           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmlewis gmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @Bortlesboat!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

cc: @stevehipwell - @alexandear - @Not-Dhananjay-Mishra

Comment thread github/pulls.go Outdated
Comment thread github/pulls_stacks_test.go Outdated
Comment thread github/pulls_stacks_test.go Outdated
@Bortlesboat

Bortlesboat commented Aug 7, 2026

Copy link
Copy Markdown
Author

All three review items are addressed in signed commit 295dd70, and their threads are resolved. Local script/test.sh -covermode atomic ./..., script/lint.sh, script/fmt.sh, and script/generate.sh --check all pass. GitHub initially held the new tests, linter, and workflow-security runs at action_required; a maintainer approved them, and the full current upstream matrix is now green.

Comment thread github/pulls_stacks.go
Comment thread github/pulls_stacks.go Outdated
Comment thread github/pulls_stacks.go Outdated
@Bortlesboat

Copy link
Copy Markdown
Author

Thanks, both differences check out against the OpenAPI description. Pushed 5ad53ca.

base is {ref} only on all five stack endpoints, so it no longer reuses
PullRequestStackBase — that type stays as-is for PullRequest.Stack, where
base really is {ref, sha}. The stack endpoints now use a new
PullRequestStackRef.

On the list endpoint: the difference is in pull_requests. List items are
{number, state, draft, merged_at, head{ref, sha}}, while create/get/add/unstack
return Pull Request Stack Pull Request, which is Pull Request Minimal
(id, number, url, head/base with a nested repo) plus node_id,
title, state, merged_at, draft, html_url, and user. So ListStacks
now returns []*PullRequestStackMinimal and the other four return
*PullRequestStackDetails. The head/base shapes differ too (list has no
repo), hence the separate branch types.

Also dropped omitempty and the pointers on the required fields per your other
comment. The old test fixture was sending the list-shaped pull_requests for
every endpoint, so there are two fixtures now.

@Not-Dhananjay-Mishra Not-Dhananjay-Mishra left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few struct name suggestions.

Comment thread github/pulls_stacks.go Outdated
Comment thread github/pulls_stacks.go Outdated
Comment thread github/pulls_stacks.go Outdated
Comment thread github/pulls_stacks.go Outdated
Comment thread github/pulls_stacks.go Outdated
@Bortlesboat

Copy link
Copy Markdown
Author

Took the stutter fixes in 7b58560, but kept the PullRequestStack prefix
rather than dropping to bare Stack*:

  • PullRequestStackPullRequest -> PullRequestStackEntry
  • PullRequestStackMinimalPullRequest -> PullRequestStackMinimalEntry
  • PullRequestStackMinimalBranch -> PullRequestStackMinimalHead

Reason for not using StackPullRequest/StackMinimalPullRequest: every other
stack type in the package is prefixed (PullRequestStack, PullRequestStackBase,
PullRequestStackDetails, PullRequestStackMinimal, ...), so those two would be
the only unprefixed ones in the group. Entry drops the repetition without
splitting the naming. Happy to go bare if you'd still rather.

I went with PullRequestStackMinimalHead over PullRequestStackHead because the
detailed responses have a head too, in PullRequestStackBranch — an unqualified
PullRequestStackHead would be ambiguous about which one it is.

On the two request types, I'd lean toward leaving them: Create<Resource>Request
is what the package mostly does (19 types — CreateIssueRequest,
CreateGistCommentRequest, CreateHostedRunnerRequest, ...) against 4 with a
service prefix, and those 4 are prefixed by service name
(ActionsCreateVariableRequest, SecretScanningCreateCustomPatternsRequest). If
you do want the service-prefixed form here, PullRequestsCreateStackRequest and
PullRequestsAddToStackRequest would at least match each other — the suggestions
as written are singular for one and plural for the other.

Comment thread github/pulls_stacks_test.go Outdated
Comment thread github/pulls_stacks.go Outdated
@Bortlesboat

Copy link
Copy Markdown
Author

Refreshed against current master in 064c6e7. The two request types now use the suggested names, and each endpoint test contains its response and expected-value fixtures directly. Accessors and iterators are regenerated.

Formatting, generated-file freshness, all 11 modules' non-race tests, and the custom lint checks pass. The focused stack endpoint tests also pass after replacing the copied pointer helpers with the current Go idiom. Local CGO remains disabled, so race coverage is left to CI.

The separate endpoint-resource and embedded pull-request membership types are preserved for the schema distinction discussed above.

Comment thread github/pulls_stacks.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NeedsReview PR is awaiting a review before merging. waiting for reply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for new stacked pull requests endpoints

4 participants