mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-03 05:00:56 +00:00
make version comparision more similar to that of dpkg
Initially found by automated repository health checks used by Termux in https://github.com/termux/termux-packages/issues/27472 The root problem was 4.3.5a comparing less than 4.3.5-rc1-1 by aptly According to debian "4.3.5a" > "4.3.5-rc1-1" This is because dpkg splits hyphen for revision at the first hyphen, whereas aptly was splitting at the last hyphen which is different from dpkg's behaviour. dpkg behaviour: https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/lib/dpkg/parsehelp.c#n242 Perhaps this wasn't detected as there was broken tests in the repository since the initial commit of aptly. This also fixes those tests
This commit is contained in:
+6
-6
@@ -30,16 +30,16 @@ func CompareVersions(ver1, ver2 string) int {
|
||||
|
||||
// parseVersions breaks down full version to components (possibly empty)
|
||||
func parseVersion(ver string) (epoch, upstream, debian string) {
|
||||
i := strings.LastIndex(ver, "-")
|
||||
if i != -1 {
|
||||
debian, ver = ver[i+1:], ver[:i]
|
||||
}
|
||||
|
||||
i = strings.Index(ver, ":")
|
||||
i := strings.Index(ver, ":")
|
||||
if i != -1 {
|
||||
epoch, ver = ver[:i], ver[i+1:]
|
||||
}
|
||||
|
||||
i = strings.Index(ver, "-")
|
||||
if i != -1 {
|
||||
debian, ver = ver[i+1:], ver[:i]
|
||||
}
|
||||
|
||||
upstream = ver
|
||||
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user