Skip to content

admin/render_readmes.rs to correctly identify the readme path #3967

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

Merged
merged 1 commit into from
Oct 1, 2021

Conversation

nipunn1313
Copy link
Contributor

Previously, it would try to get a field called readme_file
which never existed in the Cargo.toml manifest format. This
fixes it.

https://doc.rust-lang.org/cargo/reference/manifest.html#the-readme-field

I believe the confusion arose because the cargo package command
actually converts the readme contents -> readme field and the
Cargo.toml readme field -> readme_file field when making the
request to crates.io.

However, in the admin render_readme backfill, it is opening the
original Cargo.toml which has a readme field for the path.

I manually tested with a local backend/frontend and confirmed that
readme paths were being re-rendered correctly.

Manual test screenshots:

Before this change - after doing a rerender
image

After this change - after doing a rerender
image

Repro steps
Set up a local dev environment via the docs/CONTRIBUTING.md instructions.
Publish a package (I used one called innercrate) (using above instructions) with nonroot README

➜  innercrate git:(master) ✗ cat docs/README.md
Check out [other file](./Otherfile.md)
➜  innercrate git:(master) ✗ cat docs/Otherfile.md
hello world
➜  innercrate git:(master) ✗ grep readme Cargo.toml
readme = "docs/README.md"

Re-render readmes
cargo run --bin crates-admin -- render-readmes --crate innercrate
Look at http://localhost:4200/crates/innercrate

Previously, it would try to get a field called `readme_file`
which never existed in the Cargo.toml manifest format. This
fixes it.

https://doc.rust-lang.org/cargo/reference/manifest.html#the-readme-field

I believe the confusion arose because the `cargo package` command
actually converts the readme contents -> readme field and the
Cargo.toml readme field -> `readme_file` field when making the
request to crates.io.

However, in the admin render_readme backfill, it is opening the
original Cargo.toml which has a `readme` field for the path.

I manually tested with a local backend/frontend and confirmed that
readme paths were being re-rendered correctly.
@nipunn1313
Copy link
Contributor Author

Related to #3861

@nipunn1313 nipunn1313 changed the title admin/render_readmes.rs to correctly identify the readme_path admin/render_readmes.rs to correctly identify the readme path Oct 1, 2021
@Turbo87 Turbo87 added A-backend ⚙️ C-bug 🐞 Category: unintended, undesired behavior labels Oct 1, 2021
Copy link
Member

@Turbo87 Turbo87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds reasonable to me, thanks!

@Turbo87
Copy link
Member

Turbo87 commented Oct 1, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Oct 1, 2021

📌 Commit ba08285 has been approved by Turbo87

@bors
Copy link
Contributor

bors commented Oct 1, 2021

⌛ Testing commit ba08285 with merge 79d1a57...

@bors
Copy link
Contributor

bors commented Oct 1, 2021

☀️ Test successful - checks-actions
Approved by: Turbo87
Pushing 79d1a57 to master...

@bors bors merged commit 79d1a57 into rust-lang:master Oct 1, 2021
bors added a commit that referenced this pull request Oct 1, 2021
Add tests for admin/render_readmes

Depends on #3967
(Because of community/community#4477 (comment) - github ends up rendering both diffs together. Go to the commits tab and just look at the most recent commit to review).

Refactors slightly so we can add tests to the untested risky portion of this code.
I already found a couple of bugs which I will fix in follow up PRs with tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend ⚙️ C-bug 🐞 Category: unintended, undesired behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants