Skip to content

Commit

Permalink
sort according to VersionNumber comparator
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mawinter69 committed Apr 18, 2023
1 parent b6a7356 commit b3c0959
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public class PluginVersions {
public Map<String, PluginVersionsEntry> releases = new LinkedHashMap<>();

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

0 comments on commit b3c0959

Please sign in to comment.