feat(stack): add --reword flag to fix commits without staging files
What does this MR do?
Adds a --reword flag to glab stack amend that allows users to change just the commit message of a stacked diff without requiring any file changes in the working tree.
Problem
Previously, glab stack amend always required file changes — it ran checkForChanges() and addFiles() unconditionally. Users who just wanted to fix a typo in their commit message had no way to do so through the CLI.
Solution
- Add
--rewordflag that skipscheckForChanges()andaddFiles(), going straight togit commit --amend -m - When
--rewordis used without-m, the editor opens pre-populated with the existing description --rewordis mutually exclusive with--all(enforced by cobra)--rewordwith positional file args returns a clear error- Bonus fix:
amendnow updates the stack ref file'sDescriptionfield after amending, keeping stack metadata in sync with the actual commit message (this was a pre-existing bug affecting all amend operations)
Usage
# Reword with inline message
glab stack amend --reword -m "updated commit message"
# Reword via editor (opens with existing description)
glab stack amend --rewordTest coverage
4 new test cases covering:
- Reword with
-mflag on a clean working tree - Reword without
-mopens editor with existing description --reword+--allrejected as mutually exclusive--reword+ file args rejected with clear error- Stack ref description updated after reword
Closes #7649 (closed)