Skip to content

feat(stack): add mergify stack squash command#1266

Merged
mergify[bot] merged 1 commit intomainfrom
devs/jd/worktree-squash/add-mergify-stack-squash-cmd--558e6e6f
Apr 21, 2026
Merged

feat(stack): add mergify stack squash command#1266
mergify[bot] merged 1 commit intomainfrom
devs/jd/worktree-squash/add-mergify-stack-squash-cmd--558e6e6f

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented Apr 20, 2026

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.

@jd
Copy link
Copy Markdown
Member Author

jd commented Apr 20, 2026

This pull request is part of a Mergify stack:

# Pull Request Link
1 feat(stack): add mergify stack squash command #1266 👈

@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 20, 2026 13:41 Failure
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 20, 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)(?:\(.+\))?:

🟢 🔎 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,})

Comment thread skills/mergify-stack/SKILL.md Outdated
Comment thread skills/mergify-stack/SKILL.md
@mergify mergify Bot requested a review from a team April 20, 2026 13:49
@jd jd force-pushed the devs/jd/worktree-squash/add-mergify-stack-squash-cmd--558e6e6f branch from 6e5abfd to 96320ff Compare April 20, 2026 14:08
@jd
Copy link
Copy Markdown
Member Author

jd commented Apr 20, 2026

Revision history

# Type Changes Date
1 initial 6e5abfd 2026-04-20 14:08 UTC
2 content 6e5abfd → 96320ff 2026-04-20 14:08 UTC
3 rebase 96320ff → 24e8198 2026-04-21 08:01 UTC
4 content 24e8198 → dd97d10 2026-04-21 08:53 UTC

@jd jd force-pushed the devs/jd/worktree-squash/add-mergify-stack-fixup-cmd--98a90fd7 branch from c624cda to f9e9116 Compare April 20, 2026 14:08
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 20, 2026 14:08 Failure
Base automatically changed from devs/jd/worktree-squash/add-mergify-stack-fixup-cmd--98a90fd7 to main April 21, 2026 07:59
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 21, 2026

@jd this pull request is now in conflict 😩

@mergify mergify Bot added the conflict label Apr 21, 2026
Copilot AI review requested due to automatic review settings April 21, 2026 08:01
@jd jd force-pushed the devs/jd/worktree-squash/add-mergify-stack-squash-cmd--558e6e6f branch from 96320ff to 24e8198 Compare April 21, 2026 08:01
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 21, 2026 08:02 Failure
@mergify mergify Bot removed the conflict label Apr 21, 2026
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 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.

Comment thread mergify_cli/stack/squash.py Outdated
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
@jd jd force-pushed the devs/jd/worktree-squash/add-mergify-stack-squash-cmd--558e6e6f branch from 24e8198 to dd97d10 Compare April 21, 2026 08:53
@mergify mergify Bot deployed to Mergify Merge Protections April 21, 2026 08:54 Active
@jd jd marked this pull request as ready for review April 21, 2026 09:03
@mergify mergify Bot requested a review from a team April 21, 2026 09:09
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 21, 2026

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

mergify Bot added a commit that referenced this pull request Apr 21, 2026
mergify Bot added a commit that referenced this pull request Apr 21, 2026
@mergify mergify Bot added the queued label Apr 21, 2026
mergify Bot added a commit that referenced this pull request Apr 21, 2026
@mergify mergify Bot merged commit d643997 into main Apr 21, 2026
19 checks passed
@mergify mergify Bot deleted the devs/jd/worktree-squash/add-mergify-stack-squash-cmd--558e6e6f branch April 21, 2026 13:21
@mergify mergify Bot removed the queued label Apr 21, 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