feat: add smart_rebase algorithm for merged commit handling#1098
feat: add smart_rebase algorithm for merged commit handling#1098
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. 🔴 🤖 Continuous IntegrationThis rule is failing.
🔴 👀 Review RequirementsThis rule is failing.
🔴 🔎 ReviewsThis rule is failing.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
There was a problem hiding this comment.
Pull request overview
Adds a new stack sync/rebase flow that queries GitHub to detect already-merged stack commits and, when present, performs a single interactive rebase that drops those commits while rebasing onto trunk. This is wired into mergify stack push and covered by a new test suite for sync status detection and the smart_rebase() decision logic.
Changes:
- Introduce
mergify_cli/stack/sync.pywithget_sync_status(),_write_drop_script(), andsmart_rebase(). - Update
mergify stack pushrebase step to usesmart_rebase()and log how many merged commits were dropped. - Add comprehensive tests covering merged vs remaining commit classification and
smart_rebase()behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
mergify_cli/stack/sync.py |
Implements merged-commit detection via GitHub API and a drop-on-rebase mechanism using GIT_SEQUENCE_EDITOR. |
mergify_cli/stack/push.py |
Switches push-time rebase logic from git pull --rebase to smart_rebase(). |
mergify_cli/tests/stack/test_sync.py |
Adds unit tests for sync status detection, drop script behavior, and smart_rebase() decision paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return status | ||
|
|
||
|
|
||
| async def stack_sync( |
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: I74e9b3acbc71ea6eb3cc343c137174a68b20a254 Claude-Session-Id: 2d9f4a52-4a1d-4a50-a459-3b57847dec9f
6cbd57b to
7a61561
Compare
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.