Skip to main content

Module pushed_tree

Module pushed_tree 

Source
Expand description

Run a pre-push check against what is being PUSHED.

rust-test and run-tests-js take their file set from the pushed refs — correct — and then run the suite with current_dir set to the developer’s working tree. So the suite can pass on an uncommitted fix, or fail on an uncommitted experiment, and in neither case has it tested the commits being pushed. Same gap as the pre-commit one, from the other end.

§Why not the stash

Holding unstaged changes aside is the pre-commit answer, and it is the wrong instrument here. A push is not a staging operation: the difference that matters is not tree-versus-index but tree-versus-the-commit-you-are-sending, and that includes everything staged-but-uncommitted too. Setting all of it aside for the length of a test suite would leave the developer looking at a tree that is not theirs for minutes at a time.

§What it costs, which is the whole question

git worktree add --detach <tip> materialises the pushed commit somewhere else and the suite runs there. The tree is untouched, and an interrupted run leaves a worktree rather than a mangled checkout.

The cost is real: a second checkout, and a build that cannot reuse the primary tree’s target/ cache, so the first push after this lands is a cold build. That is why it is opt-in — git config greengate.testPushedTree true — rather than the default. The default keeps today’s behaviour and now SAYS what it is testing, which was the actual bug: not that it used the tree, but that nobody knew it did.

Structs§

PushedTree
A checkout of the pushed commit, removed when it goes out of scope.

Constants§

SNAPSHOT_ENV
Set to 1 on what a snapshot runs to prepare itself — the dependency install and greengate.snapshotPrepare — for a custom prepare script that wants to know. INFORMATION, not the guard: the guard is MARKER, a file in the snapshot’s git dir, which cannot leak into another repository the way an inherited variable does.
SOURCE_WORKTREE_ENV
The environment variable naming the source working tree (see PREPARE).

Functions§

enabled
Whether the user asked for the accurate-but-slower answer.
in_push_snapshot
Is dir inside a greengate push snapshot? Err when that cannot be told — which the caller must treat as “do not write”, never as “no”.
prepare_command
probe_marker
Is the marker at path? Three answers, not two: Path::exists folds “cannot look” into “absent”, and absent is the answer that bakes.
ran_on_tip
Did gate run in a checkout of tip — the pushed content itself, not whatever the working tree held?
where_to_run
Where a pre-push suite should run, and whether that is the honest answer.