feat: add smart_rebase algorithm for merged commit handling#1115
Conversation
|
This pull request is part of a stack: |
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 ⛓️ Depends-On RequirementsWonderful, this rule succeeded.Requirement based on the presence of
🟢 🤖 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.
|
fdd8a2d to
06101a3
Compare
e7028dc to
5f86e50
Compare
06101a3 to
e27a5a4
Compare
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
e27a5a4 to
e1821bb
Compare
There was a problem hiding this comment.
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.pywithget_sync_status()andsmart_rebase()plus a helper to generate aGIT_SEQUENCE_EDITORdrop script. - Updates
stack_push()togit fetchand then callsmart_rebase()instead of always doinggit pull --rebase. - Adds a comprehensive new test module for sync/rebase behavior and adjusts the shared
git_mockfixture to mockfetch.
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.
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
|
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 -ithat 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 pushduring its rebase step.Claude-Session-Id: 2d9f4a52-4a1d-4a50-a459-3b57847dec9f
Depends-On: #1114