rlsbl.commands.init_cmd

Init command: scaffold release infrastructure from templates.

Functions

file_hash

def file_hash(path)

SHA-256 hash of a file's contents.

load_hashes

def load_hashes()

Load stored file hashes from .rlsbl/hashes.json.

save_hashes

def save_hashes(hashes)

Write file hashes to .rlsbl/hashes.json.

process_template

def process_template(template_content, vars_dict)

Process a template string by replacing {{varName}} placeholders with values.

Returns (content, unreplaced) where unreplaced is a list of unmatched var names.

_save_base

def _save_base(target, content)

Save rendered template content as the merge base for future three-way merges.

_load_base

def _load_base(target)

Load the stored merge base for a target file. Returns None if not stored.

_three_way_merge

def _three_way_merge(ours_text, base_text, theirs_text)

Three-way merge using git merge-file.

Writes three temp files in the project dir (not /tmp), runs git merge-file -p ours base theirs, and returns (merged_text, has_conflicts). Exit code: 0 = clean merge, positive = number of conflicts, negative = error.

process_mappings

def process_mappings(template_dir, mappings, vars_dict, force, update=False, existing_hashes=None)

Process a list of template mappings: read each template, apply vars, write target files.

Uses a universal three-way merge (via git merge-file) for existing files: base (last scaffolded version) + ours (user's current file) + theirs (new template). USER_OWNED files are never overwritten or merged (except LICENSE year update).

Returns (created, skipped, warnings, new_hashes). created/skipped are lists of (target, status) tuples for unified display.

_finalize_scaffold

def _finalize_scaffold(existing_hashes, all_hash_dicts, created, skipped, warnings, registry=None, flags=None, registries=None)

Shared post-processing for scaffold: chmod, hooks, version marker, hashes, tagging, summary.

all_hash_dicts is a list of dicts to merge into existing_hashes. flags is the CLI flags dict (used for tagging check). registries is a list of registry names (used for tagging).

run_cmd

def run_cmd(registry, args, flags)

Init command handler.

Scaffolds release infrastructure (CI, publish workflows, changelog, etc.) from templates.

run_cmd_multi

def run_cmd_multi(registries_list, args, flags)

Scaffold for multiple registries with a merged publish workflow.

Uses the primary registry for template vars and CI, then writes a merged publish.yml that contains jobs for all detected registries.