Repository navigation
deb: split Debian revision at the last hyphen #1646
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
Open
twaik
wants to merge
1
commit into
aptly-dev:master
Choose a base branch
from
twaik:fix-version-split-last-hyphen
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
You sure? From
lib/dpkg/parsehelp.c(https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/lib/dpkg/parsehelp.c):Look at the comment which I added with
[SEETHIS]in dpkg's source, it seems to actually split at the first hyphen (unless I am missing something else).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.
Looking again slightly deeper. Yeah the docs to mention that it should be splitted at last hyphen, but dpkg is doing something different internally.
The incompatibility I believe exists in dpkg's
lib/dpkg/version.c:and aptly's
CompareVersionPartdeb/version.go: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.
strrchrlooks for the last occurence unlikestrchrwhich looks for the first one.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.
Ah okay, makes sense then (somehow I didn't read it properly). But the test case I added back in 836d9f3 for
4.3.5aand4.3.5rc1-1needs to be left as is.So for
CompareVersions()it should return1(-1 for left side is greater, 0 for equal, 1 for right side)Yeah I was wrong in that commit for how the hyphen is supposed to split, but I still believe that
CompareVersionPart()behaviour differs from that of dpkg's behaviour looking at how this breaksThere 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'm a bit unsure about the sign here, so correct me if I'm wrong
dpkg --compare-versions 4.3.5a lt 4.3.5-rc3-1is true, so I'd expect-1(the old1passed only because of the first-hyphen split).For the sign convention:
CompareVersions("1.0", "2.0")returns-1in aptly, anddpkg --compare-versions 1.0 lt 2.0is true, so-1means "first is lower" in both.I also ran every pair from
TestCompareVersionsthroughdpkg --compare-versionsmanually, and with this PR all of them match dpkg (before it, three didn't:4.3.5avs4.3.5-rc3-1,1.0+a-1vs1.0-a-1, and1.6.0-rc1+really1.6.0-0vs1.6.0-rc1-0).