fix(packages): list highest CRAN version in PACKAGES index (#39793)

Fixes https://github.com/go-gitea/gitea/issues/35728

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Mitrahsoftandwxiaoguang authored and GitHub committed 2026-10-17 06:48:48 +00:00
1 parent 42b1f95261
commit efb0b34395
6 files changed
+74 -41

No files matched your search

+4 -4
View File
@@ -52,7 +52,7 @@ func naturalSortTrimZeros(num string) string {
}
// NaturalSortCompare compares two strings so that they could be sorted in natural order
func NaturalSortCompare(s1, s2 string) int {
func NaturalSortCompare(s1, s2 string) (ret int) {
// There is a bug in Golang's collate package: https://github.com/golang/go/issues/67997
// text/collate: CompareString(collate.Numeric) returns wrong result for "0.0" vs "1.0" #67997
// So we need to handle the number parts by ourselves
@@ -70,8 +70,7 @@ func NaturalSortCompare(s1, s2 string) int {
}
if cmp := strings.Compare(num1, num2); cmp != 0 {
return cmp // equal digit count, so byte order is numeric order
}
return len(part1) - len(part2) // equal value, fewer leading zeros sorts first
} // else: naturally equal value, leave it to the outer return
}
} else {
if cmp := c.CompareString(part1, part2); cmp != 0 {
@@ -80,5 +79,6 @@ func NaturalSortCompare(s1, s2 string) int {
}
pos1, pos2 = end1, end2
}
return len(s1) - len(s2)
// each field is naturally equal, just use string comparison: "v1.02.3" < "v1.2.03"
return strings.Compare(s1, s2)
}
+3 -1
View File
@@ -21,6 +21,8 @@ func TestNaturalSortLess(t *testing.T) {
testLess("", "a")
testLess("", "1")
testLess("v1.02.3", "v1.2.03")
testLess("1.01.0", "1.1.1")
testLess("v1.2", "v1.2.0")
testLess("v1.2.0", "v1.10.0")
testLess("v1.20.0", "v1.29.0")
@@ -42,7 +44,7 @@ func TestNaturalSortLess(t *testing.T) {
testLess("0.txt", "1.txt")
testLess("file0001", "file2")
testLess("a8", "a08")
testLess("a08", "a8")
testLess("00", "1")
testLess("0", "00") // equal value, fewer leading zeros sorts first
}