On this page
Refuse a commit that teaches Cargo
No Wisent build, test or install runs Cargo: kompilator builds and tests
every Rust package, and Stado installs and stages its binaries. A page,
script or program that tells its reader or its process to run cargo build,
cargo test or cargo run teaches what no product does, and every copy of it
teaches it again.
Every stado quality check, the pre-push check a Git dispatcher
runs (--pre-push) and the check of one revision (--revision) therefore
read each checked commit's added lines, after its instance values and before
any gate, and refuse a line that runs a Cargo subcommand (build, test,
check, run, install, uninstall, fmt, clippy, fix, metadata,
update, fetch, generate-lockfile, clean, bench, doc, add,
remove, new, init, publish, vendor, tree, search, rustc,
rustdoc, pkgid, yank, owner; cargo add is the manifest line
written and kompilator lock), the word cargo standing at
the start of the line or after a space, quote, backtick, parenthesis, tag or
path, or that starts the program "cargo":
cause: stado.quality.check.cargo-instructed
<revision> adds <count> line(s) that run Cargo, and no Wisent build, test or install runs Cargo: …
README.md:5: `cargo build`
README.md:7: `cargo test`
Write the command that does the work instead:
| Instead of | Write |
|---|---|
cargo build --release --bin NAME |
kompilator build --manifest-path <dir>/Cargo.toml --release --bin NAME, or stado product kompilator stage --bin NAME with WISENT_OUTPUT_DIR naming where it goes |
cargo test --test NAME -- ARGS |
kompilator test --manifest-path <dir>/Cargo.toml --test NAME -- ARGS |
cargo install --path . |
stado product install --surface cli <product> |
cargo fmt --check, cargo clippy |
nothing: no Wisent gate formats or lints Rust, so the line is removed |
cargo metadata --no-deps |
kompilator metadata --manifest-path <dir>/Cargo.toml |
A changelog is history and is not read. A file that names Cargo's commands
to recognize them, as a gate that refuses cargo build does, is exempted by
a line of the commit message of its own:
Names Cargo: rust/src/gate/words.rs, docs/gate
A line names paths or directories, separated by commas; a directory covers
every file below it. Every other added line is still read. The real journey
is tests/quality/cargo_lines.rs (quality-cargo-lines): the real pre-push
check over commits that add a cargo build and a cargo test line, refused
with each named, and over a kompilator line, a changelog line and an
exempted file, which pass.
What a revision still holds
The check refuses a line a commit adds; the lines a tree held before it are read with:
stado quality cargo-lines [--root <checkout>] [--revision <commit>] [--json]
It reads every line of the committed revision (the checkout's HEAD when no
--revision is given, never the working tree, so another session's
uncommitted edit neither adds lines nor hides them) with git grep, leaves
out the changelogs, and prints each line that runs Cargo, by the same rule
the check applies, as <path>:<line>: <command>. With --json it answers
one document, {root, revision, lines: [{path, line, command, text}]}. A
file a commit message exempts with Names Cargo: is listed too: a tree has
no message, and the reading is what a sweep that removes Cargo still has
before it. It exits 0 whenever the revision was read, lines or none.
Its refusals are declared under stado.quality.cargo-lines
(stado errors show stado.quality.cargo-lines): a --root that holds
no Git repository (not-a-checkout, exit 2), a --revision the checkout
holds no commit of (no-such-revision, exit 2), and a git grep that could
not be started or ended otherwise than with lines (0) or none (1)
(lines-unread, naming the arguments, the exit status and what git said).
In Stado Desktop, Releases → Available operations… → List the lines of
a revision that still run Cargo takes the repository and an optional
revision on the selected Stado API host and shows the same document.
The same journey reads a committed tree whose README runs cargo build,
whose changelog names cargo test and whose script runs kompilator build,
and requires the README line alone; and it reads a directory that is no
checkout and a revision the checkout does not hold, and requires each
refusal.
Rewrite what kompilator takes word for word
stado quality cargo-lines --rewrite [--root <checkout>] [--json]
kompilator's build, test and metadata take Cargo's words once the
manifest is named, so a command cargo build|test|metadata that names
--manifest-path and whose every flag is one kompilator takes (build:
--manifest-path, --release, --bin, --out, --cache, --jobs,
--incremental, --features, --no-default-features, --all-features,
--revision; test: the same but --bin, and --test, --lib;
metadata: --manifest-path alone) is rewritten to
kompilator build|test|metadata with the same flags, the rest of the line
kept. A test name Cargo takes before -- filters what each test binary
runs, and kompilator hands the words after -- to them, so it is moved
there (cargo test --manifest-path m --test t binding -- --nocapture
becomes kompilator test --manifest-path m --test t -- binding --nocapture). A command ends at the line's end or at a backtick, quote,
), ;, & or |. Every other line that runs Cargo (no manifest named, a
flag kompilator refuses such as --locked or -p, cargo fmt,
cargo install, a program started as "cargo") is listed and
left as it is: what replaces it is in the table above, and is a person's to
write. --rewrite writes the checkout's working tree, the files Git tracks
there, so the result is the checkout's to read and commit like any edit; a
changelog is neither read nor rewritten, and each line keeps its own ending.
It prints rewrote <path>:<line> and left <path>:<line>: <command>, or with
--json one document, {root, rewritten: [{path, line, text}], lines: [{path, line, command, text}]}. --rewrite takes no --revision (exit 2): a
committed revision is not written. A file that cannot be read as UTF-8 or
written back is refused as rewrite-unwritten, naming it and what the
system said; the files written before it keep their rewrite, so running it
again finishes the rest. In Stado Desktop the same is Rewrite a working
tree's Cargo lines that name their manifest as kompilator's. The journey
rewrites a README's cargo test --manifest-path line ending in CRLF and one
with a test filter, leaves its cargo build --release line, its line with
--locked and a changelog's line as they were, and requires the refusal for
a file that is no UTF-8, left untouched.
Source: this website