Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When running --locked, check formatting of store files #348

Merged
merged 1 commit into from
Oct 31, 2022

Conversation

mystor
Copy link
Collaborator

@mystor mystor commented Oct 28, 2022

This will detect issues like audits being out of order and unrecognized fields in CI, and should help avoid simple executions of cargo vet causing formatting changes locally.

The implementation isn't particularly efficient for this, in that it immediately attempts to re-serialize the file after parsing it, and then compares the results (ignoring trailing newlines). As this checks formatting, it is a string-based check, and not structural.

The similar library, which we already used for our tests, is used to allow including diffs in the output to make any issues more clear. This also required some changes to the way we read/write files from disk to keep information around.

As a side-effect of these changes, we no longer emit an extra unnecessary newline at the end of store files. This won't be detected as an error by the checker, but will be a change when run locally.

Fixes #341

This will detect issues like audits being out of order and unrecognized
fields in CI, and should help avoid simple executions of `cargo vet`
causing formatting changes locally.

The implementation isn't particularly efficient for this, in that it
immediately attempts to re-serialize the file after parsing it, and then
compares the results (ignoring trailing newlines). As this checks
formatting, it is a string-based check, and not structural.

The `similar` library, which we already used for our tests, is used to
allow including diffs in the output to make any issues more clear. This
also required some changes to the way we read/write files from disk to
keep information around.

As a side-effect of these changes, we no longer emit an extra
unnecessary newline at the end of store files. This won't be detected as
an error by the checker, but will be a change when run locally.

Fixes mozilla#341
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Notes generated by mach cargo vet are unexpectedly deleted by running mach vendor rust
2 participants