Skip to content

API reference

The public functions of scripts/sync.py, importable as standards_sync when installed. make api checks them against the last release; Policies says what counts as a breaking change.

Standards synchronization and integrity verification utility.

Maintains strict synchronization between the canonical standards repository, the active workspace root (~/Code), and dotfiles (chezmoi distribution).

find_canonical_source()

The source holding the standards; STANDARDS_REPO, when set, is the only candidate.

get_target_dirs(src_dir)

Return configured sync target directories with descriptive labels.

compute_hash(path)

Compute SHA-256 digest of a file.

check_target_file(src, dst, fname, label, quiet)

Check a single target file against source. Return True if drifted.

check_sync(src_dir, targets, quiet=False)

Verify all targets match source files byte-for-byte. Return 0 if in sync, 1 if drifted.

published_blobs(src_dir, fname)

Every version of fname this repository has committed, as git blob ids.

blob_of(path)

The git blob id of a file's current content, as git hash-object gives it.

safe_to_overwrite(src_dir, src, dst)

Whether pushing src over dst loses nothing.

It does not when dst is missing, already matches, or holds a version this repository once published. Any other content was edited in place (in ~/Code or a dotfiles copy) and is newer than the canonical source as far as anyone can tell: a push that overwrote it once replaced the workspace's AGENTS.md with an October copy. Such a file is kept.

atomic_copy(src, dst)

Copy src over dst (through a link) by renaming a temporary copy, never half written.

is_same_file(a, b)

Whether a and b are one file, as when a target links to the source.

Copying a file onto itself fails (shutil.SameFileError), and there is nothing to copy: a linked target is always in sync.

push_file(src_dir, fname, dst, force)

Push one standard file to dst; return True when an edit was kept.

push_sync(src_dir, targets, force=False)

Propagate canonical repo files to all target destinations.

A target file edited in place is kept and reported, unless force: adopt it with --pull, or overwrite it with --push --force. A target that links to the source is reported as linked and left alone.

is_stale(src_dir, src, dst)

Whether src is an earlier published version of dst: left behind, not edited.

pull_sync(src_dir, force=False)

Pull edits from ~/Code into the source, then push; [STALE] files only with force.

install_hooks(src_dir)

Install git post-commit and post-merge hooks to auto-sync on commit/pull.

build_parser()

The command-line interface; also the source of the manpage and completions.

main()

Run the command named on the command line; push when none is.