Stage deleted conflict-resolution files with index.remove, not index.add#36
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a crash when a conflict/CI-fix “resolved” file is deleted: GitPython’s index.add() can’t stage a path that no longer exists on disk, so the code now stages deletions via index.remove() instead.
Changes:
- Update
AppContext.commit_solution()to stage deleted files withindex.remove()whenitem.deleted_fileis true. - Update
commit_ci_fix_solution()to split staged paths into “add” vs “remove” based on whether the file exists on disk. - Add regression tests covering deleted-file staging for both conflict-resolution and CI-fix commits.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/mergai/app.py |
Stages deletions with index.remove() when a resolved/modified tracked file is deleted. |
src/mergai/ci/commit.py |
Avoids index.add() on deleted files by staging missing paths via index.remove(). |
tests/test_commit_solution.py |
Adds regression test ensuring commit_solution() properly stages deleted resolved files. |
tests/test_ci_fix_commit.py |
Adds regression test ensuring commit_ci_fix_solution() properly stages deleted resolved files. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
A "deleted by us"/"deleted by them" conflict resolved by removing the file leaves nothing on disk for GitPython's index.add to read, so commit_solution and commit_ci_fix_solution crashed with FileNotFoundError instead of staging the removal.
f8d4273 to
f10daa2
Compare
igorsol
approved these changes
Jul 7, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A "deleted by us"/"deleted by them" conflict resolved by removing the file leaves nothing on disk for GitPython's index.add to read, so commit_solution and commit_ci_fix_solution crashed with FileNotFoundError instead of staging the removal.
This is the bug that broke this
trigger-mergerun: https://github.com/percona/percona-server-mongodb/actions/runs/28846155368/job/85550479497 — the conflict-resolution agent correctly resolved a "deleted by us" conflict onjstests/suites/backup-restore/BUILD.bazelby deleting the file, butcommit_solution()then crashed trying toindex.add()a path that no longer existed.Verified fixed with this run, which used the same merge pick but the patched mergai build: https://github.com/plebioda/percona-server-mongodb/actions/runs/28859224967/job/85593343488 — both the
mergeandpublishsteps completed successfully.