mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-17 23:53:24 +02:00
Allow to check out branches
The git server currently lacks branch switching capabilities, limiting both LLMs and developers. This adds branch checkout so LLMs can help developers add new functionality in a new feature branch.
This commit is contained in:
24
src/git/tests/test_server.py
Normal file
24
src/git/tests/test_server.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
import git
|
||||
from mcp_server_git.server import git_checkout
|
||||
|
||||
def test_git_checkout_existing_branch(tmp_path: Path):
|
||||
# Setup test repo
|
||||
repo = git.Repo.init(tmp_path)
|
||||
Path(tmp_path / "test.txt").write_text("test")
|
||||
repo.index.add(["test.txt"])
|
||||
repo.index.commit("initial commit")
|
||||
|
||||
# Create and test branch
|
||||
repo.git.branch("test-branch")
|
||||
result = git_checkout(repo, "test-branch")
|
||||
|
||||
assert "Switched to branch 'test-branch'" in result
|
||||
assert repo.active_branch.name == "test-branch"
|
||||
|
||||
def test_git_checkout_nonexistent_branch(tmp_path: Path):
|
||||
repo = git.Repo.init(tmp_path)
|
||||
|
||||
with pytest.raises(git.GitCommandError):
|
||||
git_checkout(repo, "nonexistent-branch")
|
||||
Reference in New Issue
Block a user