Skip to content

feat(stack): add reorder command#1121

Merged
mergify[bot] merged 1 commit intomainfrom
devs/jd/feat/stack-reorder-move/I46dc35fd28e3535e9f64f85581db87a50b6d4c21
Apr 10, 2026
Merged

feat(stack): add reorder command#1121
mergify[bot] merged 1 commit intomainfrom
devs/jd/feat/stack-reorder-move/I46dc35fd28e3535e9f64f85581db87a50b6d4c21

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented Apr 10, 2026

Add mergify stack reorder to non-interactively reorder all commits in
a stack. Takes commit prefixes (SHA or Change-Id) in desired order and
uses a temporary Python script as GIT_SEQUENCE_EDITOR to rewrite the
rebase todo list, avoiding the sed quoting issues that make inline
GIT_SEQUENCE_EDITOR unreliable for automation.

Supports --dry-run to preview the new order without rebasing.

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

@jd
Copy link
Copy Markdown
Member Author

jd commented Apr 10, 2026

This pull request is part of a stack:

  1. feat(stack): add reorder command (#1121) 👈
  2. feat(stack): add move command (#1122)

Copilot AI review requested due to automatic review settings April 10, 2026 11:22
@mergify mergify bot had a problem deploying to Mergify Merge Protections April 10, 2026 11:22 Failure
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Apr 10, 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,})

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 reorder command to deterministically reorder all commits in the current stack (non-interactive), by driving git rebase -i with a generated Python GIT_SEQUENCE_EDITOR script, plus a dedicated test suite.

Changes:

  • Introduce mergify_cli.stack.reorder implementing stack commit discovery, prefix-to-commit matching, and automated interactive rebase reordering (with --dry-run support).
  • Add mergify stack reorder command wiring in the stack CLI.
  • Add end-to-end style tests that create a real repo + origin, then verify reorder behavior and error cases.

Reviewed changes

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

File Description
mergify_cli/stack/reorder.py Core implementation of stack commit enumeration, prefix matching, and non-interactive reorder via GIT_SEQUENCE_EDITOR.
mergify_cli/stack/cli.py Adds the stack reorder Click command and forwards args to the implementation.
mergify_cli/tests/stack/test_reorder.py New test coverage for reorder success paths and validation/error cases (SHA + Change-Id prefixes, dry-run, duplicates, empty stack).

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

Add `mergify stack reorder` to non-interactively reorder all commits in
a stack. Takes commit prefixes (SHA or Change-Id) in desired order and
uses a temporary Python script as GIT_SEQUENCE_EDITOR to rewrite the
rebase todo list, avoiding the sed quoting issues that make inline
GIT_SEQUENCE_EDITOR unreliable for automation.

Supports --dry-run to preview the new order without rebasing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Change-Id: I46dc35fd28e3535e9f64f85581db87a50b6d4c21
Claude-Session-Id: cdc0d010-0b6d-4808-a13c-d8e205472a4b
@jd jd force-pushed the devs/jd/feat/stack-reorder-move/I46dc35fd28e3535e9f64f85581db87a50b6d4c21 branch from bc1c88f to 9e71e25 Compare April 10, 2026 13:29
@mergify mergify bot deployed to Mergify Merge Protections April 10, 2026 13:29 Active
@mergify mergify bot requested a review from a team April 10, 2026 13:32
@jd jd marked this pull request as ready for review April 10, 2026 13:36
@mergify mergify bot requested a review from a team April 10, 2026 13:39
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Apr 10, 2026

Merge Queue Status

This pull request spent 5 minutes 58 seconds in the queue, including 5 minutes 15 seconds running CI.

Required conditions to merge

mergify bot added a commit that referenced this pull request Apr 10, 2026
@mergify mergify bot added the queued label Apr 10, 2026
@mergify mergify bot merged commit 2418480 into main Apr 10, 2026
19 checks passed
@mergify mergify bot deleted the devs/jd/feat/stack-reorder-move/I46dc35fd28e3535e9f64f85581db87a50b6d4c21 branch April 10, 2026 14:09
@mergify mergify bot removed the queued label Apr 10, 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