Skip to content

[2/n][sl][github][gh stacks] add support for stack endpoint - #1393

Open
raydatray wants to merge 2 commits into
facebook:mainfrom
raydatray:pr1393
Open

[2/n][sl][github][gh stacks] add support for stack endpoint#1393
raydatray wants to merge 2 commits into
facebook:mainfrom
raydatray:pr1393

Conversation

@raydatray

@raydatray raydatray commented Jul 31, 2026

Copy link
Copy Markdown

ctx

basic plumbing for github native stacks REST API

changes made

  • gh_submit: StackDetails dataclass + get_stack_for_pull_request, create_stack, add_prs_to_stack, unstack, all pinned to the 2026-03-10 preview API version
  • unstack returns the remaining stack when dissolution is partial (merged/queued diffs cannot be unstacked) so callers can react instead of assuming success
  • update_pull_request now takes base: Optional[str]: github rejects updatePullRequest mutations that include baseRefName for PRs in a native stack, so base=None uses a new mutation variant (GRAPHQL_UPDATE_PULL_REQUEST_NO_BASE) that only touches title/body

test plan

CI (doctest on _parse_stack_from_dict), and dogfooded on my own computer via a patch raydatray/rusty-mcrouter#198
Screenshot 2026-07-31 at 3 20 04 PM


Stack created with Sapling. Best reviewed with ReviewStack.

@meta-codesync

meta-codesync Bot commented Jul 31, 2026

Copy link
Copy Markdown

This pull request has been imported. If you are a Meta employee, you can view this in D114402654. (Because this pull request was imported automatically, there will not be any future comments.)

@facebook-github-tools

Copy link
Copy Markdown

@raydatray has updated the pull request. You must reimport the pull request before landing.

### ctx
github added native stacked pull requests, it would be nice to add native support to it for sapling!

this stack lets `sl pr submit` and `sl pull` via a new `github.pr.workflow = stacked` mode

### changes made
- `github_gh_cli.make_request` accepts custom headers (`-H`, needed for the `X-GitHub-Api-Version` preview header)
- `_format_param` supports list values using the `gh api` repeated-field syntax (`pull_requests[]=101`)
- an empty list is passed explicitly as `key[]` without a value (per the gh api manual) rather than dropped, since an empty array and a missing field can mean different things to an endpoint
- mock_utils: `MockGitHubServer` now tracks which expectations were consumed; tests can opt in via `wrap_with_consumption_check` to fail when an expected request silently stops happening (closes the old TODO)

### test plan
doctests in `_format_param` (registered in test-doctest.py, including the empty-array case), existing github .t suite. verified the empty-array wire format empirically: `gh api -F "pull_requests[]" --verbose` sends `{"pull_requests": []}`
### ctx
basic plumbing for github native stacks REST API

### changes made
- `gh_submit`: `StackDetails` dataclass + `get_stack_for_pull_request`,  `create_stack`, `add_prs_to_stack`, `unstack`, all pinned to the `2026-03-10` preview API version
- `unstack` returns the remaining stack when dissolution is partial (merged/queued diffs cannot be unstacked) so callers can react instead of assuming success
- `update_pull_request` now takes `base: Optional[str]`: github rejects `updatePullRequest` mutations that include `baseRefName` for PRs in a  native stack, so `base=None` uses a new mutation variant  (`GRAPHQL_UPDATE_PULL_REQUEST_NO_BASE`) that only touches title/body

### test plan
CI (doctest on `_parse_stack_from_dict`), and dogfooded on my own computer via a patch  raydatray/rusty-mcrouter#198
<img width="905" height="468" alt="Screenshot 2026-07-31 at 3 20 04 PM" src="https://github.com/user-attachments/assets/bbe461a5-4128-4c75-b603-8ef4e012bb05" />
@facebook-github-tools

Copy link
Copy Markdown

@raydatray has updated the pull request. You must reimport the pull request before landing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant