AsyncGitClient
Source: leap0/_async/git.py
Signature
Section titled “Signature”AsyncGitClient(transport: AsyncTransport)Overview
Section titled “Overview”Clone repositories, inspect diffs and history, manage branches, stage files, commit, push, and pull inside a running sandbox.
This client is useful when you want to automate Git workflows without
shelling out manually through :class:ProcessClient.
Attributes: None.
Methods
Section titled “Methods”async clone(sandbox: SandboxRef, *, url: str, path: str, branch: str | None = None, commit_id: str | None = None, depth: int | None = None, username: str | None = None, password: str | None = None, http_timeout: float | None = None) -> GitResultClone a remote repository into the sandbox.
Args: sandbox: Sandbox ID or object. url: Repository URL. path: Destination path inside the sandbox. branch: Branch to clone. commit_id: Specific commit to checkout after cloning. depth: Shallow clone depth. username: Auth username (for private repos). password: Auth password or token (for private repos).
http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: GitResult: Command output and exit status from the clone operation.
status
Section titled “status”async status(sandbox: SandboxRef, *, path: str, http_timeout: float | None = None) -> GitResultGet the current repository status.
Returns: GitResult: Git status output and exit status.
Args: sandbox: Sandbox ID or object. path: Path used by this operation. http_timeout: Optional HTTP request timeout in seconds for this SDK call.
branches
Section titled “branches”async branches(sandbox: SandboxRef, *, path: str, branch_type: str = 'local', contains: str | None = None, not_contains: str | None = None, http_timeout: float | None = None) -> GitResultList branches in the repository.
Args:
sandbox: Sandbox ID or object.
path: Path to the git repo.
branch_type: Filter by "local", "remote", or "all".
contains: Only branches containing this commit SHA.
not_contains: Exclude branches containing this commit SHA.
http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
diff_unstaged
Section titled “diff_unstaged”async diff_unstaged(sandbox: SandboxRef, *, path: str, context_lines: int | None = None, http_timeout: float | None = None) -> GitResultShow working tree changes that are not staged yet.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
diff_staged
Section titled “diff_staged”async diff_staged(sandbox: SandboxRef, *, path: str, context_lines: int | None = None, http_timeout: float | None = None) -> GitResultShow changes that are already staged for the next commit.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
async diff(sandbox: SandboxRef, *, path: str, target: str, context_lines: int | None = None, http_timeout: float | None = None) -> GitResultCompare the current state against a branch, tag, or commit.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
async reset(sandbox: SandboxRef, *, path: str) -> GitResultUnstage all currently staged changes.
Args: sandbox: Sandbox ID or object. path: Path used by this operation.
Returns: object: Result returned by this operation.
async log(sandbox: SandboxRef, *, path: str, max_count: int | None = None, start_timestamp: str | None = None, end_timestamp: str | None = None, http_timeout: float | None = None) -> GitResultShow commit history with optional limits and date filters.
Args: sandbox: Sandbox ID or object. path: Path to the git repo. max_count: Maximum number of commits to return (default 10). start_timestamp: Start timestamp filter. end_timestamp: End timestamp filter. http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
async show(sandbox: SandboxRef, *, path: str, revision: str = 'HEAD') -> GitResultShow the full output for a commit, branch, or tag revision.
Args: sandbox: Sandbox ID or object. path: Path used by this operation. revision: Parameter for this operation.
Returns: object: Result returned by this operation.
create_branch
Section titled “create_branch”async create_branch(sandbox: SandboxRef, *, path: str, name: str, checkout: bool | None = None, base_branch: str | None = None, http_timeout: float | None = None) -> GitResultCreate a new branch.
Args: sandbox: Sandbox ID or object. path: Path to the git repo. name: New branch name. checkout: Switch to the new branch immediately. base_branch: Branch from a specific revision. http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
checkout_branch
Section titled “checkout_branch”async checkout_branch(sandbox: SandboxRef, *, path: str, branch: str, create: bool | None = None, http_timeout: float | None = None) -> GitResultSwitch to an existing branch. Set create to create it if it does not exist.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
delete_branch
Section titled “delete_branch”async delete_branch(sandbox: SandboxRef, *, path: str, name: str, force: bool = False) -> GitResultDelete a branch. Set force to delete even if unmerged.
Args: sandbox: Sandbox ID or object. path: Path used by this operation. name: Name used by this operation. force: Parameter for this operation.
Returns: object: Result returned by this operation.
async add(sandbox: SandboxRef, *, path: str, files: list[str], http_timeout: float | None = None) -> GitResultStage files for the next commit.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
commit
Section titled “commit”async commit(sandbox: SandboxRef, *, path: str, message: str, author: str | None = None, email: str | None = None, allow_empty: bool | None = None, http_timeout: float | None = None) -> GitCommitResultCreate a commit from staged changes.
Args: sandbox: Sandbox ID or object. path: Path to the git repo. message: Commit message. author: Author name. email: Author email. allow_empty: Allow creating an empty commit.
http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Args:
sandbox: Sandbox ID or object.
path: Path to the git repo.
remote: Remote name (default "origin").
branch: Branch name.
set_upstream: Set upstream tracking.
username: Auth username.
password: Auth password or token.
http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: GitCommitResult: Commit result including commit ID when successful.
async push(sandbox: SandboxRef, *, path: str, remote: str | None = None, branch: str | None = None, set_upstream: bool | None = None, username: str | None = None, password: str | None = None, http_timeout: float | None = None) -> GitResultPush commits to a remote.
Args: sandbox: Sandbox ID or object. path: Path used by this operation. remote: Parameter for this operation. branch: Parameter for this operation. set_upstream: Parameter for this operation. username: Parameter for this operation. password: Parameter for this operation. http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
async pull(sandbox: SandboxRef, *, path: str, remote: str | None = None, branch: str | None = None, rebase: bool | None = None, set_upstream: bool | None = None, username: str | None = None, password: str | None = None, http_timeout: float | None = None) -> GitResultPull commits from a remote. Set rebase to rebase instead of merge.
Args:
sandbox: Sandbox ID or object.
path: Path to the git repo.
remote: Remote name (default "origin").
branch: Branch name.
rebase: Rebase instead of merge.
set_upstream: Set upstream tracking.
username: Auth username.
password: Auth password or token.
http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.