Expand description
Make a fresh snapshot runnable: carry the untracked files a suite needs, then prepare its JavaScript dependencies.
A snapshot is a checkout, not a workspace — no node_modules, no .env —
and a gate started there fails having tested nothing. Both steps run in
crate::pushed_tree::PushedTree::prepare, before greengate.snapshotPrepare
(the escape hatch), and a failure in either is the snapshot’s failure: no
suite runs, nothing is stamped.
§What a stamp may rest on
A stamp claims the gate passed on the COMMITTED content. So nothing here may put content from the developer’s tree where committed content lives: a carried path must be untracked in the snapshot’s own index, and the dependencies must be the ones the committed lockfile describes.
The default, install, is what CI does: npm ci, pnpm install --frozen-lockfile, yarn install --frozen-lockfile (yarn 1) or
--immutable (berry, told apart by the lockfile’s __metadata: block).
A bun lockfile is recognised and refused with the fix named, never
installed: a gate run over no dependencies fails every workspace at once
and reads like a broken branch. reuse (pnpm and npm; yarn and bun always
install, see voucher) clones the working tree’s node_modules and keeps
the clone only when the manager vouches for it: pnpm by its isolated layout
and a frozen offline install, npm by a dry-run install that would add,
remove and change nothing. Both catch a missing or wrong-version package, a
stray directory, and a manifest the lockfile does not satisfy; npm also
catches a version raised in place with its timestamps set back. NEITHER
catches a file edited in place without a version change: the mtime scan
covers that only while the edit is newer than the install. That limit is
why reuse is opt-in.
Every question about a manifest goes to the package manager, through exit
codes and parseable output: this crate is dependency-free and has no JSON
or YAML parser, and a hand-rolled one reading workspaces would be a
second, divergent answer to a question npm already answers.
Structs§
- Unit
- One installation unit: a directory holding a tracked lockfile, and the manager that reads it.
Enums§
Functions§
- carry
- Copy the untracked files
greengate.snapshotCarrynames fromsourceintosnapshot. - carry_
list greengate.snapshotCarry, split on whitespace and commas.- changed_
since_ upstream - The files
tipchanges relative to where it forked from its upstream — what the push is about.Nonewhen git cannot say (no upstream, a tip it does not know): the caller then prepares everything. - declared_
manager - The
packageManagerfield of a package.json, by a targeted scan of that one key — the manager it names (npm@…,pnpm@…,yarn@…,bun@…) when it names one without ambiguity,Noneotherwise. - deps
- Prepare the dependencies of every unit the push needs in
snapshot. - deps_
mode - is_
berry_ lock - Is this
yarn.lockyarn 2+’s? Berry writes a__metadata:block at the top of every lockfile; yarn 1 writes# yarn lockfile v1and never that key. Read from the SNAPSHOT’s lockfile, so the pushed commit decides. - lockfile_
dirs_ in - The directories of
filesnamed exactlyname, repo-relative (""for the root), sorted and deduplicated. Pure: the caller decides WHICH index the list comes from — the snapshot’s, for a snapshot. - run
- Carry → dependencies → nothing else;
snapshotPrepareruns after this, inPushedTree::prepare. Dependencies are skipped when asnapshotPreparecommand exists: that command owns them. - select_
units - Which units a snapshot needs: the root one, and every unit that is the
NEAREST enclosing unit of a changed file. A unit the push does not touch
cannot hold a failure the push introduced — and nothing the gates run for
this push reads it — so installing it is pure cost (website-builder: seven
spikes, an install each, on every snapshot).
changedisNonewhen the range is unknown, and then every unit is kept. - snapshot_
files - The snapshot’s own tracked files,
-z, with git’s environment stripped: a hook’sGIT_DIR/GIT_INDEX_FILEwould otherwise answer for the developer’s repository, and the pushed tip — not HEAD, not the index the developer is staging into — decides what the snapshot holds. - units
- Every installation unit in
files. A directory holding MORE THAN ONE manager’s lockfile is settled bypackageManager, or refused: guessing would install the wrong tree and test it as if it were the right one.