Baldwin

Python versions PyPI - Version GitHub tag (with filter) License GitHub commits since latest release (by SemVer including pre-releases) CodeQL QA Tests Coverage Status Dependabot Documentation Status mypy uv pytest Ruff Downloads Stargazers pre-commit Prettier Follow @Tatsh Mastodon Follow

This is a conversion of my simple scripts to version my home directory with very specific excludes and formatting every file upon commit so that readable diffs can be generated.

Commands

bw

Manage a home directory with Git.

Usage

bw [OPTIONS] COMMAND [ARGS]...

auto-commit

Automated commit of changed and untracked files.

Usage

bw auto-commit [OPTIONS]

Options

-d, --debug

Enable debug logging.

format

Format changed and untracked files.

Usage

bw format [OPTIONS]

Options

-d, --debug

Enable debug logging.

git

Wrap git with git-dir and work-tree passed.

Usage

bw git [OPTIONS] [ARGS]...

Options

-d, --debug

Enable debug logging.

Arguments

ARGS

Optional argument(s)

info

Get basic information about the repository.

Usage

bw info [OPTIONS]

Options

-d, --debug

Enable debug logging.

init

Start tracking a home directory.

Usage

bw init [OPTIONS]

Options

-d, --debug

Enable debug logging.

install-units

Install systemd units for automatic committing.

Usage

bw install-units [OPTIONS]

Options

-d, --debug

Enable debug logging.

hgit

Wrap git with git-dir and work-tree passed.

Usage

hgit [OPTIONS] [ARGS]...

Options

-d, --debug

Enable debug logging.

Arguments

ARGS

Optional argument(s)

Library

baldwin module.

Baldwin library.

class baldwin.lib.RepoInfo(git_dir_path: Path, work_tree_path: Path)

General repository information.

git_dir_path : Path

Git directory.

work_tree_path : Path

Work tree.

async baldwin.lib.auto_commit() None

Automated commit of changed and untracked files.

async baldwin.lib.format_(filenames: Iterable[Path | str] | None = None, log_level: 'silent' | 'error' | 'warn' | 'log' | 'debug' = 'error') None

Format untracked and modified files in the repository.

Does nothing if Prettier is not in PATH. Each file is formatted by a separate Prettier process; invocations run concurrently, bounded by the number of available CPUs.

The following plugins will be detected and enabled if found:

  • @prettier/plugin-xml

  • prettier-plugin-ini

  • prettier-plugin-sort-json

  • prettier-plugin-toml

Parameters:
filenames : Iterable[Path | str] | None

Paths to format, or None to format modified and untracked files under the home directory.

log_level : Literal['silent', 'error', 'warn', 'log', 'debug']

Value for Prettier’s --log-level option.

baldwin.lib.get_config() BaldwinConfigContainer

Get the configuration (TOML file).

Returns:

Parsed configuration, or an empty mapping if the file does not exist.

Return type:

BaldwinConfigContainer

baldwin.lib.get_git_path() Path

Get the Git directory (GIT_DIR).

This path is platform-specific. On Windows, the Roaming AppData directory will be used.

Returns:

The path to the Git directory.

Return type:

Path

baldwin.lib.get_repo() Repo

Get a git.Repo object.

Also disables GPG signing for the repository.

Returns:

The repository object.

Return type:

Repo

baldwin.lib.git(args: Iterable[str]) None

Front-end to git with git-dir and work-tree passed.

Parameters:
args : Iterable[str]

Arguments to pass to git after the --git-dir and --work-tree options.

baldwin.lib.init() None

Start tracking a home directory.

Does nothing if the Git directory already exists.

baldwin.lib.install_units() None

Install systemd units for automatic committing.

Raises:

FileNotFoundError – If the bw executable is not found in PATH.

baldwin.lib.repo_info() RepoInfo

Get general repository information.

Returns:

Paths to the Git directory and work tree.

Return type:

RepoInfo

baldwin.lib.set_git_env_vars() None

Set environment variables for Git.

Typing helpers.

class baldwin.typing.BaldwinConfigContainer

Container for Baldwin configuration.

Indices and tables