Skip to content

Commit fded736

Browse files
authored
Minor docs updates (#343)
* clarify push behavior * max stack size * clarify only pushing active branches * no stack obj in pull_request.opened event
1 parent 9421bd6 commit fded736

7 files changed

Lines changed: 34 additions & 19 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,13 @@ gh stack sync --prune
347347

348348
### `gh stack push`
349349

350-
Push all branches in the current stack to the remote.
350+
Push active branches in the current stack to the remote.
351351

352352
```
353353
gh stack push [flags]
354354
```
355355

356-
Pushes every branch to the remote using `--force-with-lease --atomic`. This is a lightweight wrapper around `git push` that knows about all branches in the stack. It does not create or update pull requests — use `gh stack submit` for that.
356+
Pushes every active branch (excluding merged and queued branches) in one `git push` using explicit per-branch `--force-with-lease` checks. The update is not atomic: branches whose leases pass may update even if another branch is rejected. Fix the rejected branch and rerun the command; branches already updated will be unchanged. This command does not create or update pull requests — use `gh stack submit` for that.
357357

358358
| Flag | Description |
359359
|------|-------------|

cmd/push.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ func PushCmd(cfg *config.Config) *cobra.Command {
1919

2020
cmd := &cobra.Command{
2121
Use: "push",
22-
Short: "Push all branches in the current stack to the remote",
23-
Long: `Push all branches in the current stack to the remote.
24-
25-
Uses --force-with-lease and --atomic to ensure safe, all-or-nothing pushes.
26-
Merged and queued branches are automatically skipped. This command is safe to
27-
run repeatedly — it will only update branches that have changed.`,
28-
Example: ` # Push all stack branches to the default remote
22+
Short: "Push active branches in the current stack to the remote",
23+
Long: `Push active branches in the current stack to the remote.
24+
25+
Uses explicit per-branch --force-with-lease checks. Updates are not atomic: a
26+
branch may update even if another branch is rejected. Fix the rejected branch
27+
and run the command again; branches already updated will be unchanged.
28+
Merged and queued branches are automatically skipped.`,
29+
Example: ` # Push active stack branches to the default remote
2930
$ gh stack push
3031
3132
# Push to a specific remote
@@ -77,7 +78,7 @@ func runPush(cfg *config.Config, opts *pushOptions) error {
7778
}
7879
s := stacks[0]
7980

80-
// Push all active branches atomically
81+
// Push all active branches with explicit per-branch leases.
8182
remote, err := pickRemote(cfg, currentBranch, opts.remote)
8283
if err != nil {
8384
if !errors.Is(err, errInterrupt) {

docs/src/content/docs/faq.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ Use `gh stack add <branch-name>` to add a new branch on top of the current stack
3333

3434
You can also add PRs to an existing stack from the GitHub UI — either a brand-new PR or an already-open PR (via the recommendation banner), added to the top of the stack. See [Adding to an Existing Stack](/gh-stack/guides/ui/#adding-to-an-existing-stack) for details.
3535

36+
### How many PRs can a stack contain?
37+
38+
A stack can contain up to **100 pull requests**. If your work requires more than 100 PRs, split it into multiple stacks.
39+
3640
### How can I modify my stack?
3741

3842
Use `gh stack modify` to restructure a stack. It opens an interactive terminal UI where you can reorder, drop, fold (combine), insert, and rename branches — then applies all changes at once. See the [Restructuring Stacks](/gh-stack/guides/modify/) guide for a full walkthrough.
@@ -119,6 +123,12 @@ jobs:
119123

120124
See the [Webhooks reference](/gh-stack/reference/webhooks/) for the full details on the `stack` object in webhook payloads, or the [REST API reference](/gh-stack/reference/rest-api/) to read the same object on demand from a pull request.
121125

126+
### Why isn't the `stack` object in my `pull_request.opened` webhook?
127+
128+
A pull request is always **created before it's added to a stack**, so the `pull_request.opened` event never includes the `stack` object — at that moment the PR isn't part of any stack yet. The same is true for any other event that fires before the PR joins a stack.
129+
130+
To learn exactly when a PR becomes part of a stack, listen for the `pull_request` event with the **`stacked`** action. It fires when a PR is added to a stack and carries the `stack` object. See the [`stacked` event](/gh-stack/reference/webhooks/#the-stacked-event) in the Webhooks reference for the full payload.
131+
122132
### How can I optimize CI usage for a stack?
123133

124134
Because a workflow runs for every PR in a stack, a large stack can multiply your CI usage. You can use the `stack` fields to selectively run jobs based on the position of the current PR in the stack.

docs/src/content/docs/guides/workflows.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ gh stack push
249249

250250
This is equivalent but distinct from updating your branch using a merge commit. The key difference is that after changing a lower branch, rebase maintains a linear commit history so the unique set of commits on each branch have clean diffs.
251251

252-
`gh stack push` then handles the force push safely via `--force-with-lease --atomic`, ensuring either all branches update or none do.
252+
`gh stack push` then handles the force push with explicit per-branch `--force-with-lease` checks. The multi-branch push is not atomic: branches whose leases pass may update even if another branch is rejected. Fix the rejected branch and rerun the command; branches already updated will be unchanged.
253253

254254
For a simpler all-in-one flow, `gh stack sync` combines fetch, rebase, and push into a single command — useful when you just need to pull in the latest upstream changes:
255255

docs/src/content/docs/reference/cli.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ gh stack rebase --committer-date-is-author-date
394394

395395
### `gh stack push`
396396

397-
Push all branches in the current stack to the remote.
397+
Push active branches in the current stack to the remote.
398398

399399
```sh
400400
gh stack push [flags]
@@ -404,7 +404,7 @@ gh stack push [flags]
404404
|------|-------------|
405405
| `--remote <name>` | Remote to push to (defaults to auto-detected remote) |
406406

407-
Pushes every branch to the remote using `--force-with-lease --atomic`. This is a lightweight wrapper around `git push` that knows about all branches in the stack. It does not create or update pull requests — use `gh stack submit` for that.
407+
Pushes every active branch (excluding merged and queued branches) in one `git push` using explicit per-branch `--force-with-lease` checks. The update is not atomic: branches whose leases pass may update even if another branch is rejected. Fix the rejected branch and rerun the command; branches already updated will be unchanged. This command does not create or update pull requests — use `gh stack submit` for that.
408408

409409
**Examples:**
410410

docs/src/content/docs/reference/webhooks.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ description: Reference for the stacked action and stack object in pull_request w
55

66
When a pull request belongs to a stack, GitHub adds a `stack` property to the `pull_request` object in webhook event payloads. This lets apps and integrations inspect the stack's ultimate target branch — not just the direct parent branch of the PR.
77

8-
The `stack` object is included in the `pull_request` webhook payload for all [pull request lifecycle events](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request) whenever the pull request is part of a stack.
9-
8+
The `stack` object is included in the `pull_request` webhook payload for [pull request lifecycle events](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request) that fire while the pull request is part of a stack.
109

10+
:::note[The `opened` event never includes a stack]
11+
A pull request is always **created before it is added to a stack**, so the `pull_request` event with the `opened` action never carries a `stack` object — at that point the PR is not yet part of any stack. Listen for the [`stacked` action](#the-stacked-event) to learn exactly when a PR joins a stack and to receive its `stack` object.
12+
:::
1113

1214
## The `stack` Object
1315

@@ -54,7 +56,7 @@ The `stack` object is **only present** when the pull request belongs to a stack.
5456

5557
## The `stacked` Event
5658

57-
GitHub delivers the `pull_request` event with the `stacked` action when a pull request is **added to a stack**. Because a PR is created before it joins a stack, this is the event to listen for when you need to know exactly when a PR becomes part of a stack.
59+
GitHub delivers the `pull_request` event with the `stacked` action when a pull request is **added to a stack**. Because a PR is always created before it joins a stack, the `opened` event never includes a `stack` object — the `stacked` action is the event to listen for when you need to know exactly when a PR becomes part of a stack.
5860

5961
| | |
6062
|---|---|

skills/gh-stack/SKILL.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ gh stack add -um "Fix auth bug" auth-fix
492492

493493
### Push branches to remote — `gh stack push`
494494

495-
Push all stack branches to the remote.
495+
Push active stack branches to the remote.
496496

497497
```
498498
gh stack push [flags]
@@ -512,7 +512,8 @@ gh stack push --remote upstream
512512

513513
**Behavior:**
514514

515-
- Pushes all active (non-merged) branches atomically (`--force-with-lease --atomic`)
515+
- Pushes all active (non-merged, non-queued) branches in one non-atomic multi-ref push with explicit per-branch `--force-with-lease` checks
516+
- Some branches may update if another is rejected; fix the rejected branch and rerun the command
516517
- Does **not** create or update pull requests — use `gh stack submit` for that
517518

518519
**Output (stderr):**
@@ -541,7 +542,8 @@ gh stack submit --auto --open
541542

542543
**Behavior:**
543544

544-
- Pushes all active (non-merged) branches atomically (`--force-with-lease --atomic`)
545+
- Pushes each active (non-merged, non-queued) branch sequentially with explicit per-branch `--force-with-lease` checks; the overall submit is not atomic
546+
- If a later branch push is rejected, earlier branch pushes and PR updates remain; fix the rejection and rerun the same command
545547
- Creates a new PR for each branch that doesn't have one (base set to the first non-merged ancestor branch)
546548
- After creating PRs, links them together as a **Stack** on GitHub (requires the repository to have stacks enabled)
547549
- If every PR in the stack has already been merged, the stack is complete and can't be extended. `submit` automatically forks your unmerged branches into a **new** stack rooted at the trunk and creates it on GitHub, leaving the merged stack untouched.

0 commit comments

Comments
 (0)