feat: Add git branch functionality and unit tests

This commit introduces the `git branch` tool to the MCP Git server, allowing users to list branches with various filtering options.

Changes include:
- Implemented `git_branch` function in `src/git/src/mcp_server_git/server.py` to support listing local, remote, and all branches, as well as filtering by `contains` and `not_contains` SHA values.
- Added comprehensive unit tests for the `git branch` functionality in `src/git/tests/test_server.py`, covering different branch types and commit filtering scenarios.
- Updated `src/git/README.md`.
This commit is contained in:
JavieHush
2025-05-28 16:18:42 +08:00
parent 6f920efa8a
commit e4d856214b
3 changed files with 117 additions and 4 deletions

View File

@@ -85,6 +85,15 @@ Please note that mcp-server-git is currently in early development. The functiona
- `repo_path` (string): Path to directory to initialize git repo
- Returns: Confirmation of repository initialization
13. `git_branch`
- List Git branches
- Inputs:
- `repo_path` (string): Path to the Git repository.
- `branch_type` (string): Whether to list local branches ('local'), remote branches ('remote') or all branches('all').
- `contains` (string, optional): The commit sha that branch should contain. Do not pass anything to this param if no commit sha is specified
- `not_contains` (string, optional): The commit sha that branch should NOT contain. Do not pass anything to this param if no commit sha is specified
- Returns: List of branches
## Installation
### Using uv (recommended)