Skip to content
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

Versions returned in the wrong order #26

Conversation

mike-spainhower
Copy link

Closes #25

@mike-spainhower
Copy link
Author

Once this is approved I can squash into one commit.

@@ -159,7 +159,7 @@ server.get('/:name', function (req, res) {
var meta = data.packageMeta(packageName);
if (!meta) return notFound(res);

var versions = data.whichVersions(packageName).sort();
var versions = data.whichVersions(packageName).sort(semver.compare);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we hide sorting inside whichVersions and rename the function to whiteVersionsSorted? This should reduce the amount of repeated code (see L213 for another copy).

@bajtos
Copy link
Collaborator

bajtos commented Oct 3, 2013

The pull request looks quite good, I appreciate that you included unit-tests for your change. I left few comments above (in code).

}
};
}
}

function getPackageVersions(packageName) {
Copy link
Author

Choose a reason for hiding this comment

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

I just DRYed two birds with one stone by adding this. Hopefully that is an acceptable alternative to altering data.js.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure, your solution is fine.

@bajtos
Copy link
Collaborator

bajtos commented Oct 23, 2013

Hi @mike-spainhower, I noticed there was no activity in your pull request for almost a month. Is there a way I can help you? We need to address the issues mentioned in this comment to get the patch merged.

@mike-spainhower
Copy link
Author

Truth be told, I got halfway through fixing those comments and then got a CouchDB registry going. I still intend to get these resolved, but I have to do it in spare time now 🐼

@evil-shrike
Copy link

Hi, I'm experiencing the same bug.
I have several versions for my package: http://myregistry/package/mypackage/latest returns array ["0.1.0","0.12.0","0.13.0","0.2.0","0.3.0","0.2.1"], obviously the "0.13.0" version should be the latest. But when I'm installing the package via npm ("npm i mypackge") I get "0.3.0" version.
If I request http://myregistry/mypackage then I get a JSON with dist-tags field equals "{"latest":"0.3.0"}".
I guest it's because versions are being sorted as strings not as numbers.
But in any way the behavior isn't consistent as if I request http://myregistry/package/mypackage/latest then I get 0.13.0 version!

So my users can't install the latest version of packages.

@mike-spainhower
Copy link
Author

@evil-shrike If you want to PR my branch to address @bajtos code review comments, we could get this through. Otherwise I'll still have to find some free time to rebase and DRY up tests.

@evil-shrike
Copy link

@mike-spainhower How can I help?
@bajtos I beleive It'd be nice to fix the bug even without tests if they are not enough good as it's pretty critical (no workaround for users except specifying version explicitly).

@bajtos
Copy link
Collaborator

bajtos commented Apr 8, 2014

@evil-shrike

How can I help?

I'd say you can fork node-reggie repo, pull changes from this pull request and address items 1,3,4,5 from my comment. Let's ignore the item 2 (file naming) for now.

Rebase the changes on the current master branch and make sure the tests are passing on Travis CI.

I beleive It'd be nice to fix the bug even without tests if they are not enough good as it's pretty critical (no workaround for users except specifying version explicitly).

That would make future changes more difficult to make. If there is nobody having enough time to improve the small amount of new code now, I don't think there will be anybody having even more time to improve all that not-good-enough code accumulated over time.

@bajtos bajtos closed this May 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Versions returned in the wrong order
3 participants