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 reorder always launched a text editor to specify the branch order.
  • glab stack infer always launched a text editor to select commits from a revision range.

This change makes both commands usable non-interactively:

  1. glab stack reorder now accepts positional branch arguments (glab stack reorder <branch>...) to reorder the stack directly without an editor.
  2. When reorder runs without branch arguments in a non-interactive environment, it fails fast with guidance naming the positional arguments syntax.
  3. Specifying branch arguments with --continue or --abort is rejected as mutually exclusive, and duplicate branch names in the arguments are rejected.
  4. glab stack infer now includes an --all (-a) flag to include all commits in the revision range without prompting.
  5. When infer runs without --all in a non-interactive environment, it fails fast with guidance to pass --all.
  6. Command help, documentation, and the bundled glab-stack skill are updated to document non-interactive usage.

Closes #8658 (closed)

How has this been tested?

I added unit tests covering:

  • Non-interactive execution of reorder with positional arguments.
  • Fail-fast error reporting when reorder runs without arguments and no TTY is available.
  • Rejection of positional branch arguments when combined with --continue or --abort.
  • Validation rejecting duplicate branch names in reorder.
  • Non-interactive execution of infer with the --all flag.
  • Fail-fast error reporting when infer runs without --all and no TTY is available.

The rest runs in the pipeline.

Implemented with AI assistance; I reviewed and tested the changes.

Merge request reports

Loading
Loading