Repository navigation
docs(git): document setting the commit identity via env vars or gitconfig - #5354
Conversation
…nfig git_commit already takes the author and committer from GIT_AUTHOR_* and GIT_COMMITTER_* in the server's environment, then from user.name/user.email in Git config (GitPython's Actor). Document both routes in a new Commit identity section, add -e lines to the Docker examples, and pin each route with protocol-level tests. Closes #619 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the commit-identity documentation and test additions.
No open issues 🎉
What changed in this PR
Documents how the Git server’s existing commit-identity handling addresses #619, without changing server behavior.
Changes:
- Explains identity lookup order and the fallback when no identity is configured.
- Adds local environment-variable and Docker configuration examples.
- Adds protocol-level tests for environment precedence, separate author/committer resolution, and home gitconfig lookup.
| File | Description |
|---|---|
src/git/tests/test_identity.py |
Adds three tests covering commit-identity configuration routes. |
src/git/README.md |
Documents commit identity and updates Docker examples with identity variables. |
Review effort: Balanced
|
Copilot round 1: clean (no findings, no suppressed comments). The review loop stops on this first clean round, with nothing pushed since. Head: 9863a10. |
Closes #619
Description
git_commitalready honors a commit identity from the environment and from Git config; it was just undocumented. It goes through GitPython'sIndexFile.commit, whoseActorreadsGIT_AUTHOR_NAME/GIT_AUTHOR_EMAILandGIT_COMMITTER_NAME/GIT_COMMITTER_EMAILfirst, thenuser.name/user.emailfrom the repository config,~/.gitconfig,$XDG_CONFIG_HOME/git/configand/etc/gitconfig. With none of them set it does not refuse (unlikegit commit): it recordsroot <root@<container id>>in Docker, which is the problem #619 describes.So no code changes. This PR:
envblock for local commands, and a read-only gitconfig mount for Docker (the image runs asroot, so/root/.gitconfig);-e GIT_*pairs to the two Docker examples (Usage with Claude Desktop, and Development);tests/test_identity.py, which pins each route through the protocol: the env vars override repo config, author and committer are resolved separately, and a~/.gitconfigunderHOMEis used when no env var is set.Server Details
mcp-server-git)Motivation and Context
#619: users running the server in Docker could not see how to commit under their own name. The triage comment on the issue noted that Git and GitPython already read the standard variables, so the work is documentation. This PR confirms that by test before documenting it.
How Has This Been Tested?
uv run pytest tests/test_identity.py: 3 passed;npm run local:gateexits 0.docker build -t mcp-git-619 src/git), committing a staged file in a scratch repo, in both eras (--protocol-era legacyandmodern; both returnedChanges committed successfully with hash …, exit 0). Thengit log --format='%s | %an <%ae> / %cn <%ce>':-erows useddocker run --rm -i -e "GIT_AUTHOR_NAME=Ada Author" -e GIT_AUTHOR_EMAIL=ada@example.com -e "GIT_COMMITTER_NAME=Cy Committer" -e GIT_COMMITTER_EMAIL=cy@example.com --mount … mcp-git-619. The gitconfig rows used--mount type=bind,src=<dir>/.gitconfig,dst=/root/.gitconfig,readonly. The last row (no identity at all) shows the fallback the README warns about.claude -p --strict-mcp-config), with a config running this branch throughuv --directory src/git run mcp-server-git --repository <scratch repo>and the README'senvblock (author Ada Author, committer Cy Committer). Prompt: "Using the git server, commit the already-staged changes in the repository at with the message 'llm env identity', then reply with exactly the text the tool returned." It calledgit_commitand repliedChanges committed successfully with hash 09434b6b…;git log -1showsllm env identity | Ada Author <ada@example.com> / Cy Committer <cy@example.com>. Claude Code has no era switch, so the era it negotiated could not be chosen; the Inspector runs above cover both eras.Breaking Changes
None. Existing configurations behave as before.
Types of changes
Checklist
npm run changeset) if this changes what a TypeScript server publishes (not applicable: a Python server, and docs/tests only)Additional context
This is lane E of the #5270 (Git v2.3.0) fan-out. It touches only the new README subsection, the two Docker examples and a new test file, so it merges cleanly beside the other lanes' PRs.
🤖 Generated with Claude Code