Repository navigation
fix(rust): read a single-quoted Cargo edition too - #683
Open
noahkhomer18 wants to merge 1 commit into
Open
noahkhomer18 wants to merge 1 commit into
noahkhomer18 wants to merge 1 commit into
Conversation
TOML literal strings are single-quoted, so edition = '2021' is as valid as the double-quoted form and some projects and generators write it that way. The pattern only matched double quotes, so those crates reported no edition and therefore no runtime, runtimeLatest or runtimeMajorsBehind. The capture now takes whichever quote opened the value and matches its backreference, so both styles read 2021 and the value must still be digits. Fixes vibgrate#677
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.
Closes #677.
TOML literal strings are single-quoted, so
edition = '2021'is just as valid as the double-quoted form — and some projects and generators write it that way.extractRustEditiononly matched double quotes, so those crates reported no edition, and therefore no runtime,runtimeLatestorruntimeMajorsBehindinvg scan.The capture now takes whichever quote opened the value and matches it with a backreference:
/^\s*edition\s*=\s*(["'])(\d+)\1/mThe value must still be digits, so
edition.workspace = true(tracked in #632) is untouched.Tests:
test/cargo-rust-edition.test.tscovers the single-quoted form, the double-quoted form (pinning existing behaviour) and a non-edition line.Checks: the new file plus
cargo-dependency-headerare 6/6 green.One pre-existing failure to flag:
cargo-workspace-inheritance› "inherits pins for a member and leaves path and git tables unset" fails on Windows because the scanned paths come back ascrates\appwhile the test looks upcrates/app. I confirmed it fails identically with this change stashed, so it is not from this PR.