feat(stack): add mergify stack squash command#1266
Conversation
|
This pull request is part of a Mergify stack:
|
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.
|
6e5abfd to
96320ff
Compare
Revision history
|
c624cda to
f9e9116
Compare
|
@jd this pull request is now in conflict 😩 |
96320ff to
24e8198
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new non-interactive mergify stack squash command to combine one or more “SRC” commits into a “TARGET” commit (optionally amending the final message), intended to avoid interactive rebases/editors while working with stacked PRs.
Changes:
- Implement
stack_squash()to reorder SRC commits next to TARGET and fold them via a scripted interactive rebase (with optional amend exec for-m). - Add the
mergify stack squash SRC... into TARGET [-m ...]CLI command plus a small token parser to work around Click positional limitations. - Add unit tests for both the token parser and squash behavior; document the new command in the skill doc.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| skills/mergify-stack/SKILL.md | Documents the new stack squash workflow and adds examples. |
| mergify_cli/tests/stack/test_squash_cli.py | Adds unit tests for parsing SRC... into TARGET tokens. |
| mergify_cli/tests/stack/test_squash.py | Adds integration-style tests validating reorder/fold behavior, errors, and dry-run for squash. |
| mergify_cli/stack/squash.py | Replaces the previous placeholder with the actual stack_squash implementation (incl. optional amend exec). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add "mergify stack squash SRC... into TARGET [-m MESSAGE]" which reorders SRC commits adjacent to TARGET and folds them in without opening an editor. Without -m, TARGET's message is kept (via the fixup rebase action). With -m, the rebase inserts an `exec git commit --amend -m ...` line right after the last fixup source, which runs while HEAD still points at the combined target — so prepare-commit-msg re-attaches the Change-Id normally. Errors when SRC == TARGET, when a SRC is duplicated, or when a SRC or TARGET prefix is unknown. Supports --dry-run. Click does not allow two positionals when one is variadic, so the CLI takes a single tokens tuple and parses "SRC... into TARGET" manually (_parse_squash_tokens); parser edge cases are covered by unit tests. Also documents the squash command in skills/mergify-stack/SKILL.md. Change-Id: I558e6e6f5e33252ad52f8e4a002dfc0141d693b0
24e8198 to
dd97d10
Compare
Merge Queue Status
This pull request spent 7 minutes 45 seconds in the queue, including 7 minutes 18 seconds running CI. Required conditions to merge
|
Add "mergify stack squash SRC... into TARGET [-m MESSAGE]" which reorders
SRC commits adjacent to TARGET and folds them in without opening an
editor. Without -m, TARGET's message is kept (via the fixup rebase
action). With -m, the rebase inserts an
exec git commit --amend -m ...line right after the last fixup source, which runs while HEAD still
points at the combined target — so prepare-commit-msg re-attaches the
Change-Id normally.
Errors when SRC == TARGET, when a SRC is duplicated, or when a SRC or
TARGET prefix is unknown. Supports --dry-run.
Click does not allow two positionals when one is variadic, so the CLI
takes a single tokens tuple and parses "SRC... into TARGET" manually
(_parse_squash_tokens); parser edge cases are covered by unit tests.
Also documents the squash command in skills/mergify-stack/SKILL.md.