Repository navigation
ci: the license guard's CR handling explains itself with two false claims - #1019
Merged
Merged
Conversation
…aims
`check-dependency-licenses.sh` justifies a pipeline stage like this:
# The file uses CRLF, hence the `tr -d '\r'`.
recorded="$(tail -n +2 "${CSV}" | cut -d, -f1 | tr -d '\r' | ...)"
Both halves are wrong.
**The file is not CRLF.** `dependency-licenses.csv` has zero CR bytes. It was
CRLF when the guard was written -- 111 of them at 642eacf -- and 8eb0dcf
(NVIDIA#917) normalized it to LF while touching it for something unrelated, so the
sentence has been stale since that landed.
**And the `tr` would not be needed even if it were.** A CR sits immediately
before the newline, which puts it in the CSV's *last* field. `cut -d, -f1`
reads the first. The strip has never had anything to remove on this path.
Verified rather than reasoned: converting the committed CSV to CRLF (117 CR
bytes) and running the guard with the strip removed passes exactly as it does
today. I first wrote this commit claiming the opposite -- that dropping the
strip would report every crate as missing -- and the mutation refused to
reproduce it, which is how the second error came to light. Both directions,
both line endings, all four combinations agree.
So the stage goes, and the comment now records why no CR handling belongs
there. The same reasoning applies to the `.strip("\r")` in the example-workspace
half further down, which reads `line.split(",")[0]`; that one is left alone as
one concern per change.
Happy to keep the `tr` as belt-and-braces instead and only fix the comment --
it costs nothing at runtime. I removed it because a line whose stated purpose is
false and whose effect is nil teaches the next reader something untrue about the
file format, which is how it survived this long.
Verified: guard passes on the tree as committed (57 declared crates, plus the
example-workspace half), and passes identically with the CSV converted to CRLF.
Signed-off-by: Vyncint Ng <[email protected]>
Collaborator
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
check-dependency-licenses.shjustifies a pipeline stage like this:Both halves are wrong.
1. The file is not CRLF.
dependency-licenses.csvhas zero CR bytes. It was CRLF when the guard was written — 111 of them at642eacf5— and8eb0dcf2(#917) normalized it to LF while touching it for something unrelated, so the sentence has been stale since that landed.2. The
trwould not be needed even if it were. A CR sits immediately before the newline, which puts it in the CSV's last field.cut -d, -f1reads the first. The strip has never had anything to remove on this path.So the stage goes, and the comment now records why no CR handling belongs there.
How the second error came to light
I first wrote this PR claiming the opposite — that dropping the strip would make the guard report every crate as missing — and built a mutation to demonstrate it. The mutation refused to reproduce it. Converting the committed CSV to CRLF (117 CR bytes) and running the guard with the strip removed passes exactly as it does today. Both line endings, with and without the strip: all four combinations agree.
That is the whole finding, and I would not have got it right by reading.
Scope
The same reasoning applies to the
.strip("\r")in the example-workspace half further down, which readsline.split(",")[0]. That one is left alone — one concern per change.Happy to keep the
tras belt-and-braces and only fix the comment; it costs nothing at runtime. I removed it because a line whose stated purpose is false and whose effect is nil teaches the next reader something untrue about the file format, which is how it survived this long.Testing
Local, no GPU.
cargo oxide run <example>— not applicable, CI script only