Loading
feat(stack): make reorder and infer usable without a TTY
Description
Two glab stack commands previously required an interactive terminal and failed with no TTY available when run by scripts or AI agents:
glab stack reorderalways launched a text editor to specify the branch order.glab stack inferalways launched a text editor to select commits from a revision range.
This change makes both commands usable non-interactively:
glab stack reordernow accepts positional branch arguments (glab stack reorder <branch>...) to reorder the stack directly without an editor.- When
reorderruns without branch arguments in a non-interactive environment, it fails fast with guidance naming the positional arguments syntax. - Specifying branch arguments with
--continueor--abortis rejected as mutually exclusive, and duplicate branch names in the arguments are rejected. glab stack infernow includes an--all(-a) flag to include all commits in the revision range without prompting.- When
inferruns without--allin a non-interactive environment, it fails fast with guidance to pass--all. - Command help, documentation, and the bundled
glab-stackskill are updated to document non-interactive usage.
Related Issues
Closes #8658 (closed)
How has this been tested?
I added unit tests covering:
- Non-interactive execution of
reorderwith positional arguments. - Fail-fast error reporting when
reorderruns without arguments and no TTY is available. - Rejection of positional branch arguments when combined with
--continueor--abort. - Validation rejecting duplicate branch names in
reorder. - Non-interactive execution of
inferwith the--allflag. - Fail-fast error reporting when
inferruns without--alland no TTY is available.
The rest runs in the pipeline.
Implemented with AI assistance; I reviewed and tested the changes.