Expand description
VCS-state inspection helpers for kata apply --all (#80).
Phase 1 / 2 only ever clone template repos. Phase 3 added the
ability to fan out apply across every registered project,
which immediately raises the question: is each target PJ in a
state where overwriting template-managed files is safe? An
uncommitted edit could be silently clobbered, or the apply’s
diff could be polluted with unrelated work-in-progress.
This module wraps the lightweight side of the answer:
dirty_filesrunsgit status --porcelainand returns the list of “user-dirty” paths — kata-owned bookkeeping files (.kata/applied.toml,.kata/vars*.toml) are filtered out so jj-colocated repos don’t get flagged as dirty every timegit pushmoves the upstream pointer.
Detection limitation (out of scope for this iteration): jj
workspaces that aren’t git-colocated are reported as non-git
and therefore “clean by inference”. Almost every yukimemi/* PJ
is colocated, so the git side is enough for the common case.
A native jj backend can be slotted in later behind the same
dirty_files signature.
Functions§
- commit_
paths - Stage the given paths and create a commit with
msgindir. ReturnsOk(false)when nothing was actually committed (every listed path was already in the index without changes — the usual case when the apply was a pure no-op), so callers can short-circuit the follow-upgit push. - dirty_
files - Inspect
dirfor uncommitted user work. Returns a list of relative paths the user has modified / added / removed, with kata-owned bookkeeping filtered out. Empty vec means clean. - pull_ff
- Fast-forward
dir’s current branch from its tracked remote (#94, the--pullhalf of thekata apply --allergonomics).--ff-onlyis intentional: if local commits diverge from the remote, the consumer’s working state is in a shape kata shouldn’t try to auto-merge — surface the failure and let the per-PJ error path report it. - push_
current - Push the current branch in
dirto its tracked upstream.Ok(false)when no upstream is configured (the PJ is local-only) so the caller can log a warning instead of surfacing an error — matchingpull_ff’s “missing-upstream is not a hard failure” stance.