feat(stack): add mergify stack reword command#1384
Conversation
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 🤖 Continuous IntegrationWonderful, this rule succeeded.
🟢 👀 Review RequirementsWonderful, this rule succeeded.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 🔎 ReviewsWonderful, this rule succeeded.
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
There was a problem hiding this comment.
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 eitherrewordor an injectedexec 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.
1b124e6 to
a2174ce
Compare
Revision history
|
…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
a2174ce to
09642ac
Compare
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
|
…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.
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
pickand inserts anexec git commit --amend -F <tmpfile>line right after it — the amend runs whileHEAD 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 asingle rebase-todo line. Without -m, COMMIT is marked as
rewordsogit 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.