-
Notifications
You must be signed in to change notification settings - Fork 994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to check out branches #166
Allow to check out branches #166
Conversation
src/git/tests/test_server.py
Outdated
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure we should add this test. It feels straight forward enough.
If we do add tests, we should use a proper fixture:
@pytest.fixture
def test_repository():
# Setup
temp_path = Path("temp_test_repo")
temp_path.mkdir(exist_ok=True)
# Initialize your repository here
# ...
yield temp_path
# Cleanup
shutil.rmtree(temp_path)
def test_git_checkout_existing_branch(test_repository):
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dsp-ant I think I've addressed your concern? Let me know what you think.
Overall this looks good. There are some changes I'd love to see to the test file. We either use a fixture or delete the tests. |
91039e3
to
cc4e29e
Compare
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.
cc4e29e
to
98e78c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Thank you
…it-checkout-command Allow to check out branches
Description
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.
Server Details
Motivation and Context
See #147
How Has This Been Tested?
Tested via the Claude macOS app.
Breaking Changes
No
Types of changes
Checklist