Skip to content

sync

sync

Code synchronization utilities for shipping repos to remote hosts.

snapshot(repo_path: str | Path | None = None, ref: str = 'HEAD') -> bytes

Create a tarball snapshot of the repo using git archive.

Only includes tracked files, respects .gitignore, excludes .git/.

Parameters:

Name Type Description Default
repo_path str | Path | None

Path to git repo (default: current working directory)

None
ref str

Git ref to archive (default: HEAD, can be branch/tag/commit)

'HEAD'

Returns:

Type Description
bytes

Tarball bytes (gzip compressed)

ship(host: str, remote_path: str, repo_path: str | Path | None = None, ref: str = 'HEAD', timeout: float | None = None) -> RunResult

Ship a snapshot of the repo to a remote host.

Creates a tarball of tracked files and extracts on remote.

Parameters:

Name Type Description Default
host str

SSH host

required
remote_path str

Destination directory on remote (will be created)

required
repo_path str | Path | None

Local git repo path (default: cwd)

None
ref str

Git ref to archive (default: HEAD)

'HEAD'
timeout float | None

SSH timeout

None

Returns:

Type Description
RunResult

RunResult from extraction

ship_dirty(host: str, remote_path: str, repo_path: str | Path | None = None, timeout: float | None = None) -> RunResult

Ship repo including uncommitted changes.

Uses git stash to capture working directory state, then archives. Useful for development/testing when you want to ship uncommitted code.

Parameters:

Name Type Description Default
host str

SSH host

required
remote_path str

Destination directory on remote

required
repo_path str | Path | None

Local git repo path (default: cwd)

None
timeout float | None

SSH timeout

None

Returns:

Type Description
RunResult

RunResult from extraction

ship_files(host: str, remote_path: str, files: list[str | Path], base_path: str | Path | None = None, timeout: float | None = None) -> RunResult

Ship specific files to a remote host.

Parameters:

Name Type Description Default
host str

SSH host

required
remote_path str

Destination directory on remote

required
files list[str | Path]

List of file paths to include

required
base_path str | Path | None

Base path for relative file paths (default: cwd)

None
timeout float | None

SSH timeout

None

Returns:

Type Description
RunResult

RunResult from extraction

sync(host: str, remote_path: str, repo_path: str | Path | None = None, exclude: list[str] | None = None, delete: bool = False, timeout: float | None = None) -> RunResult

Sync repo to remote using rsync (requires rsync on both ends).

More efficient for incremental updates than ship().

Parameters:

Name Type Description Default
host str

SSH host

required
remote_path str

Destination directory on remote

required
repo_path str | Path | None

Local path to sync (default: cwd)

None
exclude list[str] | None

Additional patterns to exclude

None
delete bool

Remove remote files not in source

False
timeout float | None

Timeout in seconds

None

Returns:

Type Description
RunResult

RunResult from rsync