Skip to content

Commit b43ecf8

Browse files
committed
1) Update README to contain basic build/run instructions. Remove legacy test advice.
2) Make the Unit Test insensitive to the git default branch name
1 parent 4c192ae commit b43ecf8

2 files changed

Lines changed: 27 additions & 34 deletions

File tree

src/git/README.md

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,29 @@ help you debug any issues.
285285

286286
## Development
287287

288-
If you are doing local development, there are two ways to test your changes:
288+
### Building
289289

290-
1. Run the MCP inspector to test your changes. See [Debugging](#debugging) for run instructions.
290+
[`uv`](https://docs.astral.sh/uv/) is used for development.
291291

292-
2. Test using the Claude desktop app. Add the following to your `claude_desktop_config.json`:
292+
Start by creating a fresh virtual environment:
293293

294-
### Docker
294+
```bash
295+
uv venv
296+
source .venv/bin/activate
297+
```
298+
To run the tests, type `uv run pytest`, to run the server from source use `uv run src/mcp_server_git/`.
299+
300+
To build, type `uv build`. You can then now run `mcp-server-git` command directly. Open with the inspector using `npx @modelcontextprotocol/inspector@latest mcp-server-git`.
301+
302+
To specify the Python version type `uv python pin <version>` (useful if you want to use a more recent version than the default).
303+
304+
To create the Docker container use
305+
306+
```bash
307+
docker build -t mcp/git .
308+
```
309+
310+
An example showing how to run via the Docker container is below:
295311

296312
```json
297313
{
@@ -312,32 +328,6 @@ If you are doing local development, there are two ways to test your changes:
312328
}
313329
```
314330

315-
### UVX
316-
```json
317-
{
318-
"mcpServers": {
319-
"git": {
320-
"command": "uv",
321-
"args": [
322-
"--directory",
323-
"/<path to mcp-servers>/mcp-servers/src/git",
324-
"run",
325-
"mcp-server-git"
326-
]
327-
}
328-
}
329-
}
330-
```
331-
332-
## Build
333-
334-
Docker build:
335-
336-
```bash
337-
cd src/git
338-
docker build -t mcp/git .
339-
```
340-
341331
## License
342332

343333
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

src/git/tests/test_server.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ def test_repository(tmp_path: Path):
1212
Path(repo_path / "test.txt").write_text("test")
1313
test_repo.index.add(["test.txt"])
1414
test_repo.index.commit("initial commit")
15+
16+
# Store the default branch name on the repo object for tests to use
17+
test_repo.default_branch = test_repo.active_branch.name
1518

1619
yield test_repo
1720

@@ -51,20 +54,20 @@ def test_git_branch_contains(test_repository):
5154
Path(test_repository.working_dir / Path("feature.txt")).write_text("feature content")
5255
test_repository.index.add(["feature.txt"])
5356
commit = test_repository.index.commit("feature commit")
54-
test_repository.git.checkout("master")
57+
test_repository.git.checkout(test_repository.default_branch)
5558

5659
result = git_branch(test_repository, "local", contains=commit.hexsha)
5760
assert "feature-branch" in result
58-
assert "master" not in result
61+
assert test_repository.default_branch not in result
5962

6063
def test_git_branch_not_contains(test_repository):
6164
# Create a new branch and commit to it
6265
test_repository.git.checkout("-b", "another-feature-branch")
6366
Path(test_repository.working_dir / Path("another_feature.txt")).write_text("another feature content")
6467
test_repository.index.add(["another_feature.txt"])
6568
commit = test_repository.index.commit("another feature commit")
66-
test_repository.git.checkout("master")
69+
test_repository.git.checkout(test_repository.default_branch)
6770

6871
result = git_branch(test_repository, "local", not_contains=commit.hexsha)
6972
assert "another-feature-branch" not in result
70-
assert "master" in result
73+
assert test_repository.default_branch in result

0 commit comments

Comments
 (0)