Skip to content

Yanking a crate should update its max_version #76

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

Closed
alexcrichton opened this issue Nov 24, 2014 · 12 comments
Closed

Yanking a crate should update its max_version #76

alexcrichton opened this issue Nov 24, 2014 · 12 comments

Comments

@alexcrichton
Copy link
Member

If a crate has its max version yanked, it should update the max_version field to go back to the otherwise maximum version.

@huonw
Copy link
Member

huonw commented Jan 11, 2015

Suggestions for how this would handle yanking every version of a crate (e.g. publish a crate for the first time accidentally and then yank it, leaving no valid version at all)?

@alexcrichton
Copy link
Member Author

That's a good question! I think that the returned value would just be null in that case as we just won't have a maximum version available.

@emk
Copy link

emk commented Nov 19, 2015

Right now, this bug makes it look like the Rust url crate is completely gone, leaving a big hole in the ecosystem. Apparently, this is not the case, but I was badly confused by it the other day.

SimonSapin added a commit to servo/rust-url that referenced this issue Nov 19, 2015
… to work around rust-lang/crates.io#76

0.3.0 was published and then yanked:
#135 (comment)
@SimonSapin
Copy link
Contributor

I just published url 0.4.0 to avoid confusion until this is fixed. It’s identical to 0.2.38, which is not compatible with 0.3.0 which was yanked. When the change from 0.3.0 lands again it’ll be 0.5.0. Version numbers are cheap.

@kamalmarhubi
Copy link

Surprising this issue has been around so long. Poor crates.io!

@carols10cents
Copy link
Member

Poor crates.io indeed! Let's get this issue on the mentored list :)

Here's how I see the fix for this going:

  • In the version yank function, which is called by yank and unyank (with true or false as the value for the yank parameter, respectively), add code to update the crate record's max_version value in the database.
  • If yank is false (meaning we're doing an unyank), the code can do something very similar to this code in krate.rs that updates the max_version if the vers we're unyanking is greater than the value in max_version.
  • If yank is true (meaning we're doing a yank), AND the crate's max_version is equal to the version being yanked, then we need to look up the next highest version number and set the crate max_version to that.
    • Looking up the next highest version number is a bit tricky, since we need to use semver ordering and the values are stored in the database as text.
    • So i think we're going to have to SELECT num FROM versions WHERE crate_id=(this crate's id) AND id != (the version id that we're yanking, then parse them as semver::Versions and sort them in Rust, then use the maximum one.

And also tests, we should have tests for each of these cases. This is sounding like a medium.

@retep998
Copy link
Member

And don't forget to update all the existing cases where max_version is currently yanked.

@yodaldevoid
Copy link
Contributor

Has anyone started work on this? If not, I would like to volunteer.

@yodaldevoid
Copy link
Contributor

One situation that has not been covered is if the version being yanked is the last unyanked version. Should the max version be set to zero, the current version, or the max yanked version?

@retep998
Copy link
Member

retep998 commented Mar 1, 2017

@yodaldevoid Is this earlier comment not sufficient?

@yodaldevoid
Copy link
Contributor

@retep998 Ah, thank you for reminding me of that. Guess I should take a short break if I am missing a comment in a set of 11 comments.

@carols10cents
Copy link
Member

We decided to remove the max_version column instead, in #592.

Turbo87 pushed a commit to Turbo87/crates.io that referenced this issue Dec 7, 2022
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Turbo87 pushed a commit to Turbo87/crates.io that referenced this issue Jan 4, 2023
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants