Skip to content

Stage deleted conflict-resolution files with index.remove, not index.add#36

Merged
plebioda merged 1 commit into
masterfrom
fix-removed-file-conflict
Jul 7, 2026
Merged

Stage deleted conflict-resolution files with index.remove, not index.add#36
plebioda merged 1 commit into
masterfrom
fix-removed-file-conflict

Conversation

@plebioda

@plebioda plebioda commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

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-merge run: https://github.com/percona/percona-server-mongodb/actions/runs/28846155368/job/85550479497 — the conflict-resolution agent correctly resolved a "deleted by us" conflict on jstests/suites/backup-restore/BUILD.bazel by deleting the file, but commit_solution() then crashed trying to index.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 merge and publish steps completed successfully.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with index.remove() when item.deleted_file is 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.

Comment thread src/mergai/ci/commit.py Outdated
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.
@plebioda plebioda force-pushed the fix-removed-file-conflict branch from f8d4273 to f10daa2 Compare July 7, 2026 10:24
@plebioda plebioda requested a review from igorsol July 7, 2026 10:42
@plebioda plebioda merged commit aa14b12 into master Jul 7, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants