-
Notifications
You must be signed in to change notification settings - Fork 211
Serve /crate/latest/crate rather than redirect #1527
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking care of this topic :) It seems to happily serve the latest version :)
Some thoughts / missing things:
- Do you mind adding some tests for this behavior?
- the crate-page should probably also serve
/latest/
instead of the redirect? (/crate/crate_name/latest/
) - the main doc-redirect too? (
/crate_name/
should probably redirect to/crate_name/latest/
, not the specific version)
I'm not sure I'm missing a place where we should change a link to /latest/
instead of the version. @Nemo157 ? @jyn514 ?
Alright, I've added test cases for the crate page redirects, and the doc redirects are covered by the existing test cases, which I updated. Ready for re-review. |
@jsha do you mind implementing my |
Alright, re-did with MatchSemver::Latest. That was less work than I had worried it would be, and you're right that it's tidier. |
@@ -351,7 +355,11 @@ fn match_version( | |||
{ | |||
return Ok(MatchVersion { | |||
corrected_name, | |||
version: MatchSemver::Semver((version.to_string(), *id)), | |||
version: if input_version == Some("latest") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember we also need to handle newest
and *
. Can you add a test case for those?
version: if input_version == Some("latest") { | |
version: if req_version == "*" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought what we discussed above was that *
and newest
should continue to have their current behavior. That's why I specifically went for input_version
rather than req_version
(which gets set to *
for all three cases).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My impression was they should redirect to latest, not to the exact version. It seems weird to have that be inconsistent.
(But uhhh yeah I did forget they should redirect, oops)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In what context are *
and newest
exposed? Part of why I wanted to leave these as-is is that I don't fully understand the use case for these alternate names. Are they a fully supported feature? How do people get to them?
I think supporting these by redirecting to latest
will require an additional clause in each of the places we redirect, so I want to make sure this is something we want to do before going ahead with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they are fully supported in that we document them on https://docs.rs/about/redirections. "typing a url manually into the browser" is something I want to support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at fixing this and it complicates the code somewhat. We'd have to add a fourth MatchSemver variant, RedirectToLatest or similar. I propose to let *
and newest
continue to redirect to an exact version. It seems slightly weird, but it has the advantage of continuing the current behavior and not overcomplicating the code (and being less work :-D).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, ok - it doesn't seem like the worst thing to have a way to opt-in to the old behavior :)
Hi @jsha, do you know when you'll get a chance to look at this again? It's almost done I think, it just needs a few updates to the tests :) (#1527 (comment)) |
Thanks for the ping! I'll try to work on this this weekend. In addition to the tests there's also a pending request for a change in functionality ( |
Updated and ready for re-review, pending resolution of #1527 (comment). |
@jsha Can you also update the crate details page to point to the "platform" and "details" dropdowns are also using version numbers: also if you don't mind it would be nice to remove the merge commit by rebasing, but I don't feel strongly about that. |
Will do. Also there's a similar issue going from the doc page, via the menu, to the crate page - if you're on To clarify: you said "crate details page to point to /latest unconditionally," but I think the right logic is "all links to versioned URLs point to /latest if the current page is /latest, or the version of the current page otherwise." Do you agree? Regarding rebases: My general preference is to squash everything into one commit before merge, and also to not rebase or squash mid-review, so reviewers can easily see the diffs between revisions. In other words, please never hesitate to ask me to rebase, I'm happy to do it. I'm also of course happy to adapt to a "rebase after each round of feedback" approach if that works better for you. |
Oh oops, good catch, that's what I meant :)
Sounds great, thanks! |
Pushed some fixes to the crate page and friends. That wound up being more involved than I expected, so please take a close look. I added some tests for those behaviors. I also added a "Permalink" under the crate menu to link to a versioned URL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks great :) thanks for writing so many tests!
Yep, let's do this in a followup PR.
I'd like to propose also doing this in a followup PR. It's fairly isolatable and is in the general category of "start directing more traffic to the /latest/ URLs," along with updating the sitemap and changing crate.io. I pushed some commits, but I just realize my fix for the builds page is incorrect (goes to a versioned page, but that's not actually what we want). I'll work on that some more and push again later today. |
Hmm, no that seems correct to me - we want to show a permalink because people often copy/paste it into a github issue. |
This looks good to me as soon as you squash and fix the clippy lint :) thank you so much for sticking with this! |
Part of #1438