Skip to content

Commit b3c0959

Browse files
committed
sort according to VersionNumber comparator
the file plugin-versions.json is the base for sorting the releases of a plugin on the plugins page at https://plugins.jenkins.io The sorting with string causes wrong ordering in some cases as described in jenkins-infra/plugin-site#1336 By sorting with the Comparator of VersionNumber we get the same sorting as in other places.
1 parent b6a7356 commit b3c0959

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/main/java/io/jenkins/update_center/json/PluginVersions.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public class PluginVersions {
2020
public Map<String, PluginVersionsEntry> releases = new LinkedHashMap<>();
2121

2222
PluginVersions(Map<VersionNumber, HPI> artifacts) {
23-
// TODO this is suboptimal sorting (we'd rather sort by VersionNumber, not its string representation) but imitates existing behavior
24-
for (VersionNumber versionNumber : artifacts.keySet().stream().sorted(Comparator.comparing(VersionNumber::toString)).collect(Collectors.toList())) {
23+
for (VersionNumber versionNumber : artifacts.keySet().stream().sorted().collect(Collectors.toList())) {
2524
try {
2625
if (releases.put(versionNumber.toString(), new PluginVersionsEntry(artifacts.get(versionNumber))) != null) {
2726
throw new IllegalStateException("Duplicate key");

0 commit comments

Comments
 (0)