Stack diff amend should update stack description

Checklist

  • I'm using the latest version of the extension (Run glab --version)
    • Extension version: DEV
  • Operating system and version: Debian 12 Bookworm
  • Gitlab.com or self-managed instance? NA -- runs local
  • GitLab version (if self-managed) NA -- runs local
  • I have performed glab auth status to check for authentication issues (NA -- not about auth)

Summary

Given I run glab stack create foo and I modify a file and save a stack with glab stack save -m foo and I run glab stack amend -m foobar Then I should see foobar as the stack description

Now: I see foo as the stack description.

Environment

  • OS: Linux 6.1.0-21-amd64 x86_64
  • SHELL: /bin/bash
  • TERM: xterm
  • GLAB: Current glab version: DEV

Other: NA

Steps to reproduce

#!/usr/bin/env bash

set -euo pipefail

type jq || { echo "jq is required"; exit 1; }
set -x

GLAB_CMD=${1:-glab}

# Create new repo
REPO_NAME="problem-$(date +%s)"
git init "$REPO_NAME"
pushd "$REPO_NAME" 2>/dev/null
echo >> "README.md"
git add README.md
git commit -m "Initial commit"

# Create a new stack
echo >> "README.md"
$GLAB_CMD stack create foo
$GLAB_CMD stack save -m 'foo'

# Amend the stack
echo >> "README.md"
$GLAB_CMD stack amend -m 'foo

bar'

# Show what glab stack knows
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
# grab the string after the last -
STACK_NAME=${BRANCH_NAME##*-}
STACK_FILE=$(find .git/stacked/foo/ -name "${STACK_NAME}*.json")
jq '.' < "$STACK_FILE"
set +x
echo '^ Should read foo\n\nbar'

What is the current bug behavior?

glab stack amend does not update the stack description in .git/stacked/<stack>/<sha>.json

What is the expected correct behavior?

glab stack amend does update the stack description in .git/stacked/<stack>/<sha>.json

Relevant logs and/or screenshots

+ GLAB_CMD=glab
++ date +%s
+ REPO_NAME=problem-1724251656
+ git init problem-1724251656
Initialized empty Git repository in /go/problem-1724251656/.git/
+ pushd problem-1724251656
/go/problem-1724251656 /go
+ echo
+ git add README.md
+ git commit -m 'Initial commit'
[master (root-commit) ddb1b0e] Initial commit
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
+ echo
+ glab stack create foo
New stack created with title "foo".
+ glab stack save -m foo
• foo: Saved with message: "foo".
+ echo
+ glab stack amend -m 'foo

bar'
Amend commit:  [glab-stack-foo-c17ead73 5684eac] foo
 Date: Wed Aug 21 14:47:36 2024 +0000
 1 file changed, 2 insertions(+)

Amended stack item with description: "foo\n\nbar".
++ git rev-parse --abbrev-ref HEAD
+ BRANCH_NAME=glab-stack-foo-c17ead73
+ STACK_NAME=c17ead73
++ find .git/stacked/foo/ -name 'c17ead73*.json'
+ STACK_FILE=.git/stacked/foo/c17ead73.json
+ jq .
{
  "prev": "",
  "branch": "glab-stack-foo-c17ead73",
  "sha": "c17ead73",
  "next": "",
  "mr": "",
  "description": "foo"
}
^ description should read "foo\n\nbar"

Possible fixes

In glab stack amend in addition to updating git, update json stored in .git/stacked

Edited by Tyler Cipriani