-
Notifications
You must be signed in to change notification settings - Fork 7
feat: add intelligent conflict resolution to rebase skill #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
andyhorn
wants to merge
1
commit into
main
Choose a base branch
from
feat/rebase-skill-conflict-resolution
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+69
−13
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,36 +67,92 @@ If they match, the branch is already up-to-date. Inform the user and stop. | |
| git rebase origin/<base-branch> | ||
| ``` | ||
|
|
||
| ### On success | ||
| ### Clean rebase (no conflicts) | ||
|
|
||
| Report how many commits ahead of the base branch: | ||
| Report success briefly: | ||
|
|
||
| - How many commits were replayed (`git rev-list --count origin/<base-branch>..HEAD`) | ||
| - The branch is now up to date with `origin/<base-branch>` | ||
| - If the branch was previously pushed, mention that a force-push (`git push --force-with-lease`) will be needed to update the remote — but do NOT push automatically | ||
|
|
||
| If changes were stashed in Step 1, restore them with `git stash pop`. If stash pop fails due to conflicts, inform the user and suggest `git stash show` to review the stashed changes. | ||
|
|
||
| ## Step 4: Handling conflicts | ||
|
|
||
| When `git rebase` stops with conflicts: | ||
|
|
||
| ### 4a. Identify conflicted files | ||
|
|
||
| ```bash | ||
| git rev-list --count origin/<base-branch>..HEAD | ||
| git diff --name-only --diff-filter=U | ||
| ``` | ||
|
|
||
| ### On conflict | ||
| ### 4b. Resolve each conflicted file | ||
|
|
||
| Read the full file content and locate conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`). For each conflict chunk, decide: | ||
|
|
||
| **Auto-resolve** (the right answer is clear): | ||
|
|
||
| Abort the rebase: | ||
| - Both sides added imports or list items — combine both sets, deduplicate, maintain sort order | ||
| - Generated files (`.g.dart`, `.freezed.dart`, `.gen.dart`, lock files) — take the current branch version; note that regeneration is needed after rebase completes | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are Flutter-specific. We're trying to build a tech-agnostic plugin here, so I'd keep the generated files general without specifics. |
||
| - Formatting / whitespace-only diffs — accept either side | ||
| - One side added new code, the other didn't touch that region — take the addition | ||
| - One side modified code the other side deleted — prefer the modification, but mention it in the summary so the user can verify the deletion wasn't intentional | ||
|
|
||
| **Stop and ask the user** (the right answer requires judgment): | ||
|
|
||
| - Both sides changed the same function or logic block differently | ||
| - Business logic where correctness depends on product intent | ||
| - Anything you aren't confident about | ||
|
|
||
| When in doubt, ask. Losing someone's work is far worse than pausing to check. | ||
|
|
||
| After resolving all conflicts in a file, write the clean version and stage it: | ||
|
|
||
| ```bash | ||
| git rebase --abort | ||
| git add <resolved-file> | ||
| ``` | ||
|
|
||
| If changes were stashed in Step 1, restore them with `git stash pop`. | ||
| ### 4c. Continue the rebase | ||
|
|
||
| Inform the user that the rebase had conflicts and suggest resolving manually: | ||
| ```bash | ||
| git rebase --continue | ||
| ``` | ||
|
|
||
| Multi-commit rebases may produce conflicts at multiple steps. Repeat 4a-4c for each. | ||
|
|
||
| ### 4d. After all conflicts are resolved, report | ||
|
|
||
| - Every conflict that was resolved, with a one-line explanation of what you chose | ||
| - Any files flagged for regeneration | ||
| - Suggest running the project's build/test/format/analyze commands to verify correctness | ||
| - If the branch was previously pushed, mention that a force-push (`git push --force-with-lease`) will be needed — but do NOT push automatically | ||
|
|
||
| If changes were stashed in Step 1, restore them with `git stash pop`. If `stash pop` fails due to conflicts, inform the user and suggest `git stash show` to review the stashed changes. | ||
|
|
||
| ## Step 5: Recovery | ||
|
|
||
| If the rebase enters a bad state or a conflict is too ambiguous to resolve safely: | ||
|
|
||
| > Automatic rebase failed due to conflicts. To resolve manually, run: `git rebase origin/<base-branch>` | ||
| ```bash | ||
| git rebase --abort | ||
| ``` | ||
|
|
||
| This restores the branch to its exact pre-rebase state — nothing is lost. Explain what went wrong so the user can decide how to proceed. | ||
|
|
||
| If changes were stashed in Step 1, restore them with `git stash pop`. | ||
|
|
||
| ## Gotchas | ||
|
|
||
| - If the branch has already been pushed to a remote, rebasing rewrites history. The user will need to force-push (`git push --force-with-lease`) after a successful rebase — warn them. | ||
| - `git stash pop` can itself cause conflicts if stashed changes overlap with rebased commits. If stash pop fails, inform the user and suggest `git stash show` to review the stashed changes. | ||
| - Detached HEAD state (`HEAD` instead of a branch name) means the user is not on any branch. Inform them and stop — do not attempt to rebase. | ||
| - If the base branch does not exist locally but does on the remote, `git fetch` in Step 2 will create the remote tracking ref. The rebase uses `origin/<base-branch>`, not the local branch. | ||
|
|
||
| ## Important | ||
| ## Rules | ||
|
|
||
| - This skill only manages git state. Do not modify project files. | ||
| - Never force-push unless the user explicitly asks. | ||
| - Never squash, reorder, or edit commits during the rebase — just replay them. | ||
| - Never proceed on a dirty working tree without the user's consent. | ||
| - Prefer keeping both sides' changes when combining — err on the side of inclusion. | ||
| - After resolving conflicts, always recommend running build, test, format, and analyze to verify. | ||
| - This skill only manages git state. Do not modify project files outside of conflict resolution. | ||
| - If changes were stashed, always restore them — even if the rebase fails. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im not sure 100% it needs to be there but this might be added to allowed-tools, to not ask user for allow running this. This is safe command