Skip to content

feat(stack): add mergify stack reword command#1384

Merged
mergify[bot] merged 1 commit intomainfrom
devs/jd/feat/stack-reword/add-mergify-stack-reword-cmd--c8d3c0b7
May 11, 2026
Merged

feat(stack): add mergify stack reword command#1384
mergify[bot] merged 1 commit intomainfrom
devs/jd/feat/stack-reword/add-mergify-stack-reword-cmd--c8d3c0b7

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented May 7, 2026

Add "mergify stack reword COMMIT [-m MESSAGE]" which changes a single
commit's message non-interactively, replacing the manual
"GIT_SEQUENCE_EDITOR='sed -i ... pick → reword' git rebase -i" recipe.

With -m, the rebase keeps COMMIT as pick and inserts an exec git commit --amend -F <tmpfile> line right after it — the amend runs while
HEAD still points at the target, so prepare-commit-msg re-attaches the
Change-Id via the existing hook. Multi-line messages are passed via the
temp file rather than -m "...", so they survive embedding into a
single rebase-todo line. Without -m, COMMIT is marked as reword so
git stops and opens $GIT_EDITOR for that commit only — convenient in a
TTY, but it will hang in agent contexts (pass -m to stay non-interactive).

Errors when COMMIT prefix is unknown. Supports --dry-run.

Also documents the reword command in skills/mergify-stack/SKILL.md.

Copilot AI review requested due to automatic review settings May 7, 2026 13:56
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 7, 2026 13:56 Failure
@jd jd temporarily deployed to func-tests-live May 7, 2026 13:56 — with GitHub Actions Inactive
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 7, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 🤖 Continuous Integration

Wonderful, this rule succeeded.
  • all of:
    • check-success=ci-gate

🟢 👀 Review Requirements

Wonderful, this rule succeeded.
  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?:

🟢 🔎 Reviews

Wonderful, this rule succeeded.
  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new mergify stack reword command to change a single commit message (either non-interactively via -m/--message or interactively via $GIT_EDITOR) by driving an interactive rebase under the hood, and documents the workflow in the stack skill guide.

Changes:

  • Introduces mergify stack reword COMMIT [-m MESSAGE] [--dry-run] CLI command.
  • Implements the reword logic using run_action_rebase() with either reword or an injected exec git commit --amend -F <file> step.
  • Adds a dedicated pytest suite covering SHA/Change-Id targeting, multiline messages, dry-run, and empty-stack behavior; updates stack documentation.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
skills/mergify-stack/SKILL.md Documents the new stack reword command and recommended usage.
mergify_cli/tests/stack/test_reword.py Adds tests validating the new reword behavior (including multiline and Change-Id targeting).
mergify_cli/stack/reword.py Implements the stack_reword() operation, including the exec ... --amend -F non-interactive path.
mergify_cli/stack/cli.py Wires the new reword subcommand into the stack CLI group.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mergify_cli/stack/reword.py Outdated
Comment thread mergify_cli/stack/reword.py Outdated
@mergify mergify Bot requested a review from a team May 7, 2026 14:11
@jd jd marked this pull request as ready for review May 7, 2026 15:00
@jd jd force-pushed the devs/jd/feat/stack-reword/add-mergify-stack-reword-cmd--c8d3c0b7 branch from 1b124e6 to a2174ce Compare May 7, 2026 15:34
@jd
Copy link
Copy Markdown
Member Author

jd commented May 7, 2026

Revision history

# Type Changes Reason Date
1 initial 1b124e6 2026-05-07 15:34 UTC
2 content 1b124e6 → a2174ce (raw) address copilot review: drop the finally that nukes the temp message file on rebase conflict (so git rebase --continue can still read it), and align the displayed action plan with the rebase action a… 2026-05-07 15:34 UTC
3 content a2174ce → 09642ac (raw) tweak comment wording: '/tmp' → 'system temp directory' (tempfile.mkstemp honours $TMPDIR; matches the same wording fix in #1386 squash.py) 2026-05-08 14:24 UTC

@jd jd temporarily deployed to func-tests-live May 7, 2026 15:35 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 7, 2026 15:35 Failure
@jd jd temporarily deployed to func-tests-live May 7, 2026 15:35 — with GitHub Actions Inactive
jd added a commit that referenced this pull request May 8, 2026
…icts

`stack_squash` with `-m` writes the new commit message to a temp file
and inserts an `exec git commit --amend -F <tmpfile>` line in the
rebase todo. The previous code wrapped the rebase in `try/finally` so
the temp file was unlinked even when the rebase failed mid-way (e.g.
conflicts on a fixup line that runs before the exec). After the user
resolved conflicts and ran `git rebase --continue`, git would replay
the exec line and fail because the message file no longer existed.

Drop the `finally`; only unlink on the success path. If the rebase
raises SystemExit, the file persists so `--continue` can still execute
the amend. The temp file lives in `/tmp` and gets cleaned by the OS.

Same pattern (and same fix) as `stack_reword` — flagged by Copilot on

Change-Id: Ia026b5b631ed043a03983beec5ca81fd29f77633
#1384 review.
Add "mergify stack reword COMMIT [-m MESSAGE]" which changes a single
commit's message non-interactively, replacing the manual
"GIT_SEQUENCE_EDITOR='sed -i ... pick → reword' git rebase -i" recipe.

With -m, the rebase keeps COMMIT as `pick` and inserts an `exec git
commit --amend -F <tmpfile>` line right after it — the amend runs while
HEAD still points at the target, so prepare-commit-msg re-attaches the
Change-Id via the existing hook. Multi-line messages are passed via the
temp file rather than `-m "..."`, so they survive embedding into a
single rebase-todo line. Without -m, COMMIT is marked as `reword` so
git stops and opens $GIT_EDITOR for that commit only — convenient in a
TTY, but it will hang in agent contexts (pass -m to stay non-interactive).

Errors when COMMIT prefix is unknown. Supports --dry-run.

Also documents the reword command in skills/mergify-stack/SKILL.md.

Change-Id: Ic8d3c0b7f74501fc3eecb5bafe4b3922af697f40
@jd jd force-pushed the devs/jd/feat/stack-reword/add-mergify-stack-reword-cmd--c8d3c0b7 branch from a2174ce to 09642ac Compare May 8, 2026 14:24
@jd jd temporarily deployed to func-tests-live May 8, 2026 14:24 — with GitHub Actions Inactive
@mergify mergify Bot deployed to Mergify Merge Protections May 8, 2026 14:24 Active
@mergify mergify Bot requested a review from a team May 11, 2026 08:28
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 11, 2026

Merge Queue Status

This pull request spent 14 minutes 31 seconds in the queue, including 14 minutes 9 seconds running CI.

Required conditions to merge

mergify Bot added a commit that referenced this pull request May 11, 2026
@mergify mergify Bot added the queued label May 11, 2026
mergify Bot pushed a commit that referenced this pull request May 11, 2026
…icts (#1386)

`stack_squash` with `-m` writes the new commit message to a temp file
and inserts an `exec git commit --amend -F <tmpfile>` line in the
rebase todo. The previous code wrapped the rebase in `try/finally` so
the temp file was unlinked even when the rebase failed mid-way (e.g.
conflicts on a fixup line that runs before the exec). After the user
resolved conflicts and ran `git rebase --continue`, git would replay
the exec line and fail because the message file no longer existed.

Drop the `finally`; only unlink on the success path. If the rebase
raises SystemExit, the file persists so `--continue` can still execute
the amend. The temp file lives in `/tmp` and gets cleaned by the OS.

Same pattern (and same fix) as `stack_reword` — flagged by Copilot on


#1384 review.
@mergify mergify Bot merged commit 301ae09 into main May 11, 2026
19 checks passed
@mergify mergify Bot deleted the devs/jd/feat/stack-reword/add-mergify-stack-reword-cmd--c8d3c0b7 branch May 11, 2026 08:50
@mergify mergify Bot removed the queued label May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants