Skip to content

feat(python-sdk): add git.log() for commit history#1528

Open
NishchayMahor wants to merge 2 commits into
e2b-dev:mainfrom
NishchayMahor:feat/python-git-log
Open

feat(python-sdk): add git.log() for commit history#1528
NishchayMahor wants to merge 2 commits into
e2b-dev:mainfrom
NishchayMahor:feat/python-git-log

Conversation

@NishchayMahor

Copy link
Copy Markdown

What

Adds Sandbox.git.log() to the Python SDK (both sync and async), returning the commit history of a repository in the sandbox as parsed GitCommit objects:

commits = sandbox.git.log("/repo", max_count=10)
for c in commits:
    print(c.hash, c.author_name, c.date, c.message)

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.pylist[GitCommit].
  • GitCommit dataclass in _git/types.py (hash, author_name, author_email, date, message), exported from e2b alongside GitStatus/GitBranches.
  • Git.log() added to sandbox_sync/git.py and sandbox_async/git.py with identical signatures.

Testing

pytest tests/shared/git/test_log.py tests/shared/git/test_parity.py tests/shared/git/test_args.py11 passed. New offline tests cover the arg builder and the parser (multi-commit, empty, malformed); test_parity.py confirms the sync/async signatures match and the async method is a coroutine. ruff and mypy clean.

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.

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.
@cla-bot

cla-bot Bot commented Jul 5, 2026

Copy link
Copy Markdown

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'

@changeset-bot

changeset-bot Bot commented Jul 5, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: bdca9dc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@NishchayMahor

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label Jul 5, 2026
@cla-bot

cla-bot Bot commented Jul 5, 2026

Copy link
Copy Markdown

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.
@NishchayMahor

Copy link
Copy Markdown
Author

Added the JS SDK side too, to keep the two SDKs in lockstep: Git.log() returning GitCommit[] with an optional maxCount, plus parseGitLog in utils.ts. Offline tests pass (vitest run tests/sandbox/git/log.test.ts → 3 passed), and tsc/oxlint are clean.

@mishushakov

mishushakov commented Jul 6, 2026

Copy link
Copy Markdown
Member

Hey, thanks for your contribution! At the time we're holding off adding new things to the git integration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants