-
Notifications
You must be signed in to change notification settings - Fork 644
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
Code and tests for issue #2567 #3458
Conversation
Hi @supergibbs, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution! The agreement was validated by .NET Foundation and real humans are currently evaluating your PR. TTYL, DNFBOT; |
Hi @supergibbs, thanks for the PR! Can you please explain what is the feature you are implementing and why this feature is important, and in what scenarios? Thanks! |
Sure, please see my #2567 (comment) |
Thanks @supergibbs . @ryuyu will review the PR and merge it. |
@supergibbs A few issues here.
This is so that we add this explicitly on only the display endpoint. The rest of the endpoints should require specifying a version (these are inserted on the page when the page is created). Thanks! |
Thanks for the notes @ryuyu. I started over off the latest |
var package = _packageService.FindPackageByIdAndVersion(id, version); | ||
|
||
Package package; | ||
if (version.Equals("prerelease", StringComparison.InvariantCultureIgnoreCase)) |
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.
Add a null check (version != null) here before we do the equals check.
Currently, it will throw if you try to go to an empty version url (Ie nuget.org/packages/{id}/)
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.
Good catch, I added a test for that too.
.Include(p => p.LicenseReports) | ||
.Include(p => p.PackageRegistration) | ||
.Where(p => (p.PackageRegistration.Id == id)) | ||
.Where(p => p.IsPrerelease) |
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.
Let's drop this condition and change the name of this method to FindAbsoluteLatestPackageById.
This way, if a package has no prerelease versions, the call to this will return whatever is the most recent.
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.
Sounds good, how do you feel about filtering out unlisted packages? I feel like that is what most owners would want. Possibly in FindPackageByIdAndVersion()
too when version is null.
@@ -32,9 +33,14 @@ public bool Match(HttpContextBase httpContext, Route route, string parameterName | |||
{ | |||
return true; | |||
} | |||
|
|||
|
|||
if (versionText.Equals("prerelease", StringComparison.InvariantCultureIgnoreCase)) |
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.
Let's change this string from "prerelease" to "absoluteLatest" or something of that nature.
With the other changes suggested, this will make it behave as expected if the most recent version is a prerelease, and it is still descriptive of the case where there are no prerelease versions.
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.
Will do. Should I add this "magic string" to the Constants.cs
/somewhere else or are you okay with it as is?
Used in two places and two tests
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.
Hmmm. Yea that seems like a good idea. Let's call it AbsoluteLatestUrlString or something of that nature.
👍 -Thanks! |
- Renamed `FindPackageByLatestPrerelease` to `FindAbsoluteLatestPackageById` - Added null version check and test
URLs like
https://www.nuget.org/packages/PACKAGE/absoluteLatest
will display the latest version.