feat(git): add git_clone tool to lean interface (#177)#179
Merged
Conversation
Adds first-class git_clone(repo_url, target_path, branch, depth, single_branch, recurse_submodules) to the lean git domain so multi-repo standardization flows no longer need the git_init + git_remote_add + git_fetch + git_checkout workaround. - Implementation in git/_remote_ops.py using Repo.clone_from with multi_options=['--branch=...', '--depth=...', '--single-branch', '--recurse-submodules'] (=-form required by GitPython arg handling). - GitClone Pydantic model in git/models.py mirrors GitInit pattern. - Re-export through git/operations.py. - ToolDefinition added to lean/registry_git.py between git_init and git_push, using model_json_schema() like git_init (not the inline dict form of git_fetch). - 7 unit tests in tests/unit/git/test_git_clone.py cover happy path, branch checkout, shallow depth (via file:// URL since local-path clone short-circuits --depth), single-branch flag, rejection of non-empty target and missing parent, and GitCommandError handling. - README.md tool count updated 50 -> 51, git count 25 -> 26. Closes #177
|
Claude finished @MementoRC's task —— View job PR Review: git_clone Tool Implementation ✅Review Checklist
Final Review SummaryOverall Assessment: EXCELLENT ⭐⭐⭐⭐⭐This PR demonstrates exemplary software engineering practices with high-quality implementation, comprehensive testing, and thorough documentation. Code Quality & Best PracticesOutstanding Strengths:
Security ConsiderationsNo Security Concerns Identified:
Performance ConsiderationsWell Optimized:
Test CoverageExceptional Testing:
DocumentationComplete and Accurate:
RecommendationsThis PR is ready for merge. No blocking issues identified. The implementation is production-ready with excellent code quality, security practices, and test coverage. Minor Enhancement Opportunities (for future consideration):
Validation Contract Compliance✅ All stated validation contracts are properly implemented and tested. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds first-class
git_clone(repo_url, target_path, branch, depth, single_branch, recurse_submodules)to the lean git domain. Closes the gap noted in the CLAUDE.md "Git Mental Model" table and removes the need for thegit_init+git_remote_add+git_fetch+git_checkoutworkaround in multi-repo standardization workflows.Changes
git/_remote_ops.py— newgit_cloneusingRepo.clone_from(...)withmulti_options=['--branch=…', '--depth=…', '--single-branch', '--recurse-submodules']. The=form is required because GitPython passes eachmulti_optionselement as a single argv togit; a--branch mainelement would be rejected.git/models.py— newGitClonePydantic model mirroringGitInit.git/operations.py— re-export sofrom .operations import git_cloneworks alongside the other tools.lean/registry_git.py—ToolDefinitionbetweengit_initandgit_push, usingGitClone.model_json_schema()(the model-based pattern fromgit_init, not the inline-dict pattern fromgit_fetch). Registered withoutwrap_repo_opsince clone does not take an existingRepo.README.md— lean interface tool count: 50 → 51, git count: 25 → 26.tests/unit/git/test_git_clone.py— 7 tests, no network, local repos as sources.Test plan
pixi run -e quality pytest tests/unit/git/test_git_clone.py -v— 7/7 passbranch=checkout,depth=1shallow (viafile://source — local-path clone short-circuits--depth),single_branch=True, rejects non-empty target, rejects missing parent, bad URL returns❌ Clone failedpixi run -e quality pytest tests/unit/git/— no regressionspixi run -e quality ruff check <changed files>— cleanpixi run -e quality ruff format --check <changed files>— cleanpyrighton changed files — cleanValidation contract
target_pathmust have an existing parent → otherwiseValueErrortarget_pathmust not exist as a non-empty directory → otherwiseValueErrorGitCommandErrorreturns❌ Clone failed: <msg>(consistent with other_remote_ops.pyerror returns)❌ Clone error: <msg>Closes #177