feat(python-sdk): add git.log() for commit history#1528
Conversation
Add Sandbox.git.log() to both the sync and async SDKs, returning parsed commit history as a list of GitCommit (hash, author name/email, ISO date, subject). Follows the existing git-command pattern (build_log_args -> _run_git -> parse_git_log) and uses a unit-separator pretty format so subjects parse cleanly. Adds offline tests for the arg builder and parser.
|
We require contributors to sign our Contributor License Agreement, and we don't have @NishchayMahor on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check' |
|
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
Mirror the new Python git.log(): add Git.log() returning parsed GitCommit[] (hash, authorName, authorEmail, ISO date, message) with an optional maxCount, plus parseGitLog and the GIT_LOG_FORMAT pretty format in utils. Keeps the two SDKs in lockstep. Adds offline tests for the parser and the method.
|
Added the JS SDK side too, to keep the two SDKs in lockstep: |
|
Hey, thanks for your contribution! At the time we're holding off adding new things to the git integration. |
What
Adds
Sandbox.git.log()to the Python SDK (both sync and async), returning the commit history of a repository in the sandbox as parsedGitCommitobjects:This rounds out the recently-expanded git module (
clone,status,branches,commit,pull, …) with commit-history inspection — a common need when an agent clones a repo into a sandbox and wants to reason about its history.How
Follows the existing git-command pattern exactly, so it's client-only (no backend change):
build_log_args(max_count)in_git/args.py— uses a unit-separator (%x1f) pretty format so subjects with spaces parse cleanly.parse_git_log()in_git/parse.py→list[GitCommit].GitCommitdataclass in_git/types.py(hash,author_name,author_email,date,message), exported frome2balongsideGitStatus/GitBranches.Git.log()added tosandbox_sync/git.pyandsandbox_async/git.pywith identical signatures.Testing
pytest tests/shared/git/test_log.py tests/shared/git/test_parity.py tests/shared/git/test_args.py→ 11 passed. New offline tests cover the arg builder and the parser (multi-commit, empty, malformed);test_parity.pyconfirms the sync/async signatures match and the async method is a coroutine.ruffandmypyclean.Happy to mirror this in the JS SDK for parity in a follow-up (or this PR) if you'd prefer to keep them in lockstep.