Skip to content

fix(git): resolve Windows permission errors during test repository teardown#4220

Open
STiFLeR7 wants to merge 1 commit into
modelcontextprotocol:mainfrom
STiFLeR7:feat/git-server-test-teardown-win
Open

fix(git): resolve Windows permission errors during test repository teardown#4220
STiFLeR7 wants to merge 1 commit into
modelcontextprotocol:mainfrom
STiFLeR7:feat/git-server-test-teardown-win

Conversation

@STiFLeR7
Copy link
Copy Markdown

Description

Fixes a Windows-specific test teardown failure in mcp-server-git tests due to:

  1. Active file handles to the index and packfiles remaining open in the git.Repo instance, causing shutil.rmtree to raise PermissionError: [WinError 32].
  2. Git object files having read-only attributes on Windows, causing shutil.rmtree to raise PermissionError: [WinError 5].

Server Details

  • Server: git
  • Changes to: tests

Motivation and Context

Developers attempting to run python tests for mcp-server-git on Windows using uv run pytest encounter permission errors during the teardown of the test_repository fixture, which halts test suite completion. This fix resolves these issues, enabling local developer testing on Windows.

How Has This Been Tested?

We verified the fix by running the test suite locally on a Windows host using:

uv run pytest

All 41 tests passed successfully with no errors (previously, 35 out of 41 tests failed during the teardown phase with PermissionError).

Breaking Changes

  • None

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling

Additional context

  • Used the standard Windows onerror pattern with shutil.rmtree to clear the read-only attribute via os.chmod prior to file removal.
  • Explicitly called test_repo.close() to release all locks and file handles held by GitPython on the repo directory.

@STiFLeR7 STiFLeR7 force-pushed the feat/git-server-test-teardown-win branch from 1e43479 to af53c65 Compare May 21, 2026 06:39
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.

1 participant