Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/git/src/mcp_server_git/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def git_create_branch(repo: git.Repo, branch_name: str, base_branch: str | None
else:
base = repo.active_branch

repo.create_head(branch_name, base)
repo.create_head(branch_name, base.commit.hexsha)
return f"Created branch '{branch_name}' from '{base.name}'"

def git_checkout(repo: git.Repo, branch_name: str) -> str:
Expand Down
12 changes: 12 additions & 0 deletions src/git/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,18 @@ def test_git_show(test_repository):
assert "show test commit" in result
assert "show_test.txt" in result

def test_git_create_branch_from_annotated_tag(test_repository):
with test_repository.config_writer() as config:
config.set_value("user", "name", "Test User")
config.set_value("user", "email", "test@example.com")
test_repository.create_tag("v1", message="release v1")

git_create_branch(test_repository, "from-tag", "v1")

branch = test_repository.heads["from-tag"]
assert branch.object.type == "commit"
assert branch.commit == test_repository.tags["v1"].commit

def test_git_show_initial_commit(test_repository):
initial_commit = list(test_repository.iter_commits())[-1]

Expand Down
Loading