Update gitpython library for git mcp server (#2948)

* bump: gitpython dependency from 3.1.43 to 3.1.45

* test: use default branch name instead of hardcoding 'master'

* fix: handle d.diff as string in GitPython 3.1.45+
This commit is contained in:
Christoph Blecker
2025-11-25 12:35:33 -08:00
committed by GitHub
parent 7fe5a635a1
commit 99813ce5c9
4 changed files with 198 additions and 188 deletions

View File

@@ -46,28 +46,32 @@ def test_git_branch_all(test_repository):
assert "new-branch-all" in result
def test_git_branch_contains(test_repository):
# Get the default branch name (could be "main" or "master")
default_branch = test_repository.active_branch.name
# Create a new branch and commit to it
test_repository.git.checkout("-b", "feature-branch")
Path(test_repository.working_dir / Path("feature.txt")).write_text("feature content")
test_repository.index.add(["feature.txt"])
commit = test_repository.index.commit("feature commit")
test_repository.git.checkout("master")
test_repository.git.checkout(default_branch)
result = git_branch(test_repository, "local", contains=commit.hexsha)
assert "feature-branch" in result
assert "master" not in result
assert default_branch not in result
def test_git_branch_not_contains(test_repository):
# Get the default branch name (could be "main" or "master")
default_branch = test_repository.active_branch.name
# Create a new branch and commit to it
test_repository.git.checkout("-b", "another-feature-branch")
Path(test_repository.working_dir / Path("another_feature.txt")).write_text("another feature content")
test_repository.index.add(["another_feature.txt"])
commit = test_repository.index.commit("another feature commit")
test_repository.git.checkout("master")
test_repository.git.checkout(default_branch)
result = git_branch(test_repository, "local", not_contains=commit.hexsha)
assert "another-feature-branch" not in result
assert "master" in result
assert default_branch in result
def test_git_add_all_files(test_repository):
file_path = Path(test_repository.working_dir) / "all_file.txt"