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 --reword flag that skips checkForChanges() and addFiles(), going straight to git commit --amend -m
  • When --reword is used without -m, the editor opens pre-populated with the existing description
  • --reword is mutually exclusive with --all (enforced by cobra)
  • --reword with positional file args returns a clear error
  • Bonus fix: amend now updates the stack ref file's Description field 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 --reword

Test coverage

4 new test cases covering:

  • Reword with -m flag on a clean working tree
  • Reword without -m opens editor with existing description
  • --reword + --all rejected as mutually exclusive
  • --reword + file args rejected with clear error
  • Stack ref description updated after reword

Closes #7649 (closed)

Merge request reports

Loading