API Docs

class darca_git.git.Git[source]

Bases: object

Core Git interface that delegates Git CLI calls through the secure DarcaExecutor. This class provides Git operations without depending on external Git libraries.

add(path: str, cwd: str) None[source]

Stage a file or path for commit.

Args:

path: Path to add (relative or absolute) cwd: Path to the repository

checkout_branch(cwd: str, branch: str, create: bool = False) None[source]

Switch to a branch (optionally creating it first).

Args:

cwd: Path to the repository branch: Branch name create: Whether to create the branch before switching

checkout_path(cwd: str, paths: str | List[str]) None[source]

Revert uncommitted changes in one or more paths.

Args:

cwd: Path to the repository paths: Single path or list of paths to restore

checkout_path_from_branch(cwd: str, branch: str, paths: str | List[str]) None[source]

Restore file(s) from a specific branch without switching branches.

Args:

cwd: Path to the repository branch: Source branch to checkout from paths: Path(s) to restore from the branch

clone(repo_url: str, cwd: str) None[source]

Clone a Git repository into the given directory.

Args:

repo_url: The Git repository URL cwd: Destination path

commit(message: str, cwd: str) None[source]

Commit staged changes with a message.

Args:

message: Commit message cwd: Path to the repository

init(cwd: str) None[source]

Initialize a Git repository in the given directory.

Args:

cwd: Directory path to initialize repo in

pull(cwd: str) None[source]

Pull the latest changes from the current branch’s remote.

Args:

cwd: Path to the repository

push(cwd: str, remote_url: str | None = None) None[source]

Push local changes to the remote repository.

Args:

cwd: Path to the repository remote_url: Optional override for the ‘origin’ remote URL

status(cwd: str, porcelain: bool = True) str[source]

Get repository status (optionally in porcelain format).

Args:

cwd: Path to the repository porcelain: Whether to use –porcelain (machine-readable)

Returns:

Git status output as string

exception darca_git.git.GitException(message, error_code=None, metadata=None, cause=None)[source]

Bases: DarcaException

Exception raised for any failure in Git operations. Provides error_code, metadata, and optional cause exception for traceability.