Skip to content

feat: add smart_rebase algorithm for merged commit handling#1115

Merged
mergify[bot] merged 2 commits intomainfrom
devs/jd/feat/pre-push-hook-intercept/If517fa97f6ed588bf1f2782aa14a1411936c9379
Apr 10, 2026
Merged

feat: add smart_rebase algorithm for merged commit handling#1115
mergify[bot] merged 2 commits intomainfrom
devs/jd/feat/pre-push-hook-intercept/If517fa97f6ed588bf1f2782aa14a1411936c9379

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented Apr 10, 2026

Adds smart_rebase() that detects merged PRs via the GitHub API and
handles them during rebase. If merged commits are found, it does a
single git rebase -i that both drops them and rebases onto trunk,
avoiding conflicts from PRs modified on GitHub before merge.

If no commits are merged, falls back to simple git pull --rebase.

Integrated into mergify stack push during its rebase step.

Claude-Session-Id: 2d9f4a52-4a1d-4a50-a459-3b57847dec9f

Depends-On: #1114

@jd
Copy link
Copy Markdown
Member Author

jd commented Apr 10, 2026

This pull request is part of a stack:

  1. style: use compact Unicode symbols instead of emoji in CLI output (#1114)
  2. feat: add smart_rebase algorithm for merged commit handling (#1115) 👈
  3. feat: add mergify stack sync CLI command (#1116)
  4. feat: add inline CI, review, and merge status to mergify stack list (#1117)

@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.

🟢 ⛓️ Depends-On Requirements

Wonderful, this rule succeeded.

Requirement based on the presence of Depends-On in the body of the pull request

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

@jd jd force-pushed the devs/jd/feat/pre-push-hook-intercept/If517fa97f6ed588bf1f2782aa14a1411936c9379 branch from fdd8a2d to 06101a3 Compare April 10, 2026 09:13
@jd jd force-pushed the devs/jd/feat/pre-push-hook-intercept/Ie9a1cbe04ce1abdd5866e9f7de6d7000e95b9675 branch from e7028dc to 5f86e50 Compare April 10, 2026 09:13
@mergify mergify bot had a problem deploying to Mergify Merge Protections April 10, 2026 09:14 Failure
@jd jd force-pushed the devs/jd/feat/pre-push-hook-intercept/If517fa97f6ed588bf1f2782aa14a1411936c9379 branch from 06101a3 to e27a5a4 Compare April 10, 2026 09:24
@mergify mergify bot had a problem deploying to Mergify Merge Protections April 10, 2026 09:24 Failure
@mergify mergify bot requested a review from a team April 10, 2026 09:27
jd added 2 commits April 10, 2026 11:32
Adds AGENTS.md with CLI output style guideline: prefer compact Unicode
symbols (✓ ✗ ● ○ —) over emoji for consistent terminal rendering.

Replaces all emoji in the stack module (setup.py, pre-push.sh) with
the compact symbols to match the queue module's existing style.

Change-Id: Ie9a1cbe04ce1abdd5866e9f7de6d7000e95b9675
Claude-Session-Id: 2d9f4a52-4a1d-4a50-a459-3b57847dec9f
Adds smart_rebase() that detects merged PRs via the GitHub API and
handles them during rebase. If merged commits are found, it does a
single `git rebase -i` that both drops them and rebases onto trunk,
avoiding conflicts from PRs modified on GitHub before merge.

If no commits are merged, falls back to simple `git pull --rebase`.

Integrated into `mergify stack push` during its rebase step.

Change-Id: If517fa97f6ed588bf1f2782aa14a1411936c9379
Claude-Session-Id: 2d9f4a52-4a1d-4a50-a459-3b57847dec9f
@jd jd force-pushed the devs/jd/feat/pre-push-hook-intercept/If517fa97f6ed588bf1f2782aa14a1411936c9379 branch from e27a5a4 to e1821bb Compare April 10, 2026 09:36
@mergify mergify bot deployed to Mergify Merge Protections April 10, 2026 09:37 Active
Base automatically changed from devs/jd/feat/pre-push-hook-intercept/Ie9a1cbe04ce1abdd5866e9f7de6d7000e95b9675 to main April 10, 2026 09:47
@jd jd marked this pull request as ready for review April 10, 2026 10:37
Copilot AI review requested due to automatic review settings April 10, 2026 10:37
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 stack “smart rebase” flow that queries GitHub for PR merge status and, when merged commits are present, rebases interactively while dropping those merged commits to reduce rebase conflicts. This is wired into the mergify stack push rebase step and includes new test coverage around the sync/rebase decision logic.

Changes:

  • Introduces mergify_cli/stack/sync.py with get_sync_status() and smart_rebase() plus a helper to generate a GIT_SEQUENCE_EDITOR drop script.
  • Updates stack_push() to git fetch and then call smart_rebase() instead of always doing git pull --rebase.
  • Adds a comprehensive new test module for sync/rebase behavior and adjusts the shared git_mock fixture to mock fetch.

Reviewed changes

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

Show a summary per file
File Description
mergify_cli/stack/sync.py New sync/rebase logic: detect merged commits and optionally drop them during rebase.
mergify_cli/stack/push.py Integrates smart_rebase() into the push flow and improves logging.
mergify_cli/tests/stack/test_sync.py New tests for merged commit detection and smart rebase branching.
mergify_cli/tests/conftest.py Extends default git mocks for fetch and branch-prefix config.
mergify_cli/stack/hooks/scripts/pre-push.sh Removes an emoji from hook output message.
AGENTS.md Adds CLI output style guidance (Unicode symbols vs emoji).

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

@mergify mergify bot requested a review from a team April 10, 2026 12:40
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Apr 10, 2026

Merge Queue Status

This pull request spent 3 minutes 11 seconds in the queue, including 2 minutes 41 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 bot added a commit that referenced this pull request Apr 10, 2026
mergify bot added a commit that referenced this pull request Apr 10, 2026
@mergify mergify bot merged commit feb0266 into main Apr 10, 2026
15 checks passed
@mergify mergify bot deleted the devs/jd/feat/pre-push-hook-intercept/If517fa97f6ed588bf1f2782aa14a1411936c9379 branch April 10, 2026 13:40
@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