Repository navigation
Add a hint to handle stacks that have closed pull requests - #612
Open
nickborromeo wants to merge 4 commits into
Open
nickborromeo wants to merge 4 commits into
nickborromeo wants to merge 4 commits into
Conversation
…ging This adds a hintClosedBlocker helper that checks if the hint for closed PRs should be displayed or not. It then uses this helper in the merge path
As we scan through the sync'd prs; we let the user know if there are any closed prs that could block the merging and allow them to handle it with the hint.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Closed-PR blockers remain hidden in some merge and sync paths, while recovery guidance can target the wrong stack or fail for last-layer cases.
5 open issues
Show closed blockers before launching the interactive merge wizard · New Check closed targets and blockers before draft guidance · New Preserve closed PR details for untracked remote stacks · New Handle closed last-layer PRs in recovery guidance · New Check out remote stacks before recommending modify and submit · New
What changed in this PR
Adds closed-pull-request diagnostics and recovery guidance to gh stack’s merge and sync workflows, helping users understand which layers are blocked.
Changes:
- Reports closed PRs during sync and identifies lower PRs that can still merge.
- Adds shared reopen/modify/submit guidance to merge errors.
- Adds regression tests and documents the recovery workflow.
| File | Description |
|---|---|
README.md |
Documents closed-PR blockers and recovery commands. |
docs/​src/​content/​docs/​reference/​cli.md |
Adds matching guidance to the CLI reference. |
cmd/​utils.go |
Introduces the shared closed-PR recovery hint. |
cmd/​sync.go |
Reports closed PRs and their effect on merging. |
cmd/​sync_test.go |
Tests closed PRs at the bottom, middle, and top. |
cmd/​merge.go |
Adds recovery hints to closed-PR merge errors. |
cmd/​merge_test.go |
Tests closed targets and blockers, plus draft-hint exclusion. |
Review effort: Max
| top := candidates[len(candidates)-1].Number | ||
| cfg.Errorf("cannot merge the whole stack: pull request #%d is %s", blocker.Number, blockerState(blocker)) | ||
| cfg.Printf("Merge up to #%d with `%s`", top, cfg.ColorAccent(fmt.Sprintf("gh stack merge %d", top))) | ||
| hintClosedBlocker(cfg, blocker) |
Comment on lines
566
to
+568
| case pr.State == "closed": | ||
| cfg.Errorf("pull request #%d is closed", prNumber) | ||
| hintClosedBlocker(cfg, pr) |
| cfg.Printf("") | ||
| cfg.Printf("Syncing PRs ...") | ||
| _ = syncStackPRs(cfg, s) | ||
| prs := syncStackPRs(cfg, s) |
Comment on lines
+673
to
+674
| cfg.Printf(" Reopen #%d, or run `%s` to drop it from the stack (or fold it to keep its changes), then run `%s` to recreate the stack on GitHub", | ||
| number, cfg.ColorAccent("gh stack modify"), cfg.ColorAccent("gh stack submit")) |
Comment on lines
+673
to
+674
| cfg.Printf(" Reopen #%d, or run `%s` to drop it from the stack (or fold it to keep its changes), then run `%s` to recreate the stack on GitHub", | ||
| number, cfg.ColorAccent("gh stack modify"), cfg.ColorAccent("gh stack submit")) |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

When a stack has a closed pull request, it is technically invalid and cannot be merged. This is not clear to the user. This change makes it so that we let the user know how to handle these cases by detecting closed pull requests in the stack when running the
mergeandsynccommands.Closed PR is the lowest unmerged layer:
Closed PR is higher up: