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

Version comparison not matching semver #1

Closed
lgommans opened this issue Apr 13, 2019 · 1 comment · Fixed by #2
Closed

Version comparison not matching semver #1

lgommans opened this issue Apr 13, 2019 · 1 comment · Fixed by #2
Labels
bug Something isn't working

Comments

@lgommans
Copy link

The version comparison does not match semver, which I assume is what Gitea follows. The code seems to do a string comparison, but whereas 1.10.0 would be more recent than 1.9.0 following semver, in string comparisons, the 9 comes after the 1 and so it would say 1.10.0' > '1.9.0' == False.

I think this should fix it:

map(int, newver.split('.')) > map(int, oldver.split('.'))

The issue with that code is that it will not support any sort of suffix, like 2.0.0-rc1. It seems those are always marked as pre-releases anyway so this should never happen when pulling the latest release, but it might still be good to have some sort of fallback for that, such as emailing the sysadmin.

The current code will only ever bug when any part of the version number (major, minor, patch) exceeds 9, and Gitea has not done that so far, but for an automatic updater that is meant to be forgotten, this might not be the best behaviour :)

By the way, I don't want to open a bunch of issues (feels like criticism), so I'll just mention it here instead: the updater is also missing any sort of verification, such as implemented here: https://gist.github.com/HorlogeSkynet/d676b9204869842933169dbe35ed8650 If this code is still in use, it might be good to implement something similar.

CMiksche added a commit that referenced this issue Apr 14, 2019
Change the version comparison to match semver. See GH-1 for more information.
@CMiksche CMiksche added the bug Something isn't working label Apr 14, 2019
CMiksche added a commit that referenced this issue Apr 20, 2019
Add a function to check the two versions after the semver specification. Added some unit tests for testing the function too.

(Should fix GH-1, but wasn't fully tested yet)
@CMiksche
Copy link
Owner

@lgommans : I've added a new function and a few unit tests to fix this problem in a new branch.

When this new function is successfully tested on a new Gitea update, i will close this issue.

Verification and the checking for a suffix should be handled in separate issues after my opinion. (I don't look at issues as criticism - i handle them as helping hands which help me being a better software developer and creating better programs ;-) )

This was referenced Apr 28, 2019
CMiksche pushed a commit that referenced this issue May 19, 2019
Add support for checksum, change to use zx, made more verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants