Skip to content

fix(embedded): Align package name sanitization with cargo-new - #12255

Merged
bors merged 5 commits into
rust-lang:masterfrom
epage:sanitize
Jun 17, 2023
Merged

bors merged 5 commits into
rust-lang:masterfrom
epage:sanitize

Conversation

@epage

@epage epage commented Jun 12, 2023 •

Copy link
Copy Markdown
Contributor

What does this PR try to resolve?

This is a follow up to #12245 which is working to resolve the tracking issue #12207

This first aligns sanitization of package names with the central package name validation logic, putting the code next to each other so they can more easily stay in sync.

Oddly enough, cargo-new is stricter than our normal package-name validation. I went ahead and sanitized along with that as well.

In working on this, I was bothered by

  • the mix of - and _ in file names because of sanitization, so I made it more consistent by detecting which the user is using
  • -using _ in bins, so I switched the default to -

How should we test and review this PR?

One existing test covers a variety of sanitization needs

Another existing test hit one of the other cases (test being reserved)

Additional information

For implementation convenience, I changed the directory we write the manifest to. The impact of this should be minimal since

  • We reuse the full file name, so if it worked for the user it should work for us
  • We should be moving away from the temp manifest in future commits

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area: Command-line interface, option parsing, etc. Command-new Command-run S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants