From a413f4eb07c1f072c0fc8addb73aa1391b0662b4 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sun, 24 Dec 2023 12:25:12 +0100 Subject: [PATCH 1/2] fix: version ordering by semver instead of date We also remove SemverException since we fixed the v1.9.2b issue. (By renaming to v1.9.2-beta.2) --- CHANGELOG.md | 4 ++ .../refinedsites/model/Component.java | 2 - .../refinedmods/refinedsites/model/Site.java | 2 - .../playbook/GithubComponentFactory.java | 51 ++++++++----------- .../refinedsites/playbook/SiteFactory.java | 8 ++- 5 files changed, 32 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 459c446..eb13461 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed + +- Fixed release version ordering. + ## [0.2.1] - 2023-12-24 ### Fixed diff --git a/src/main/java/com/refinedmods/refinedsites/model/Component.java b/src/main/java/com/refinedmods/refinedsites/model/Component.java index 61fe716..b389af4 100644 --- a/src/main/java/com/refinedmods/refinedsites/model/Component.java +++ b/src/main/java/com/refinedmods/refinedsites/model/Component.java @@ -6,11 +6,9 @@ import lombok.Builder; import lombok.Getter; import lombok.Setter; -import lombok.ToString; @Builder @Getter -@ToString(exclude = "pagesPath") public class Component { private final String name; private final boolean root; diff --git a/src/main/java/com/refinedmods/refinedsites/model/Site.java b/src/main/java/com/refinedmods/refinedsites/model/Site.java index 4b7847a..5760cb0 100644 --- a/src/main/java/com/refinedmods/refinedsites/model/Site.java +++ b/src/main/java/com/refinedmods/refinedsites/model/Site.java @@ -8,9 +8,7 @@ import com.vdurmont.semver4j.Semver; import lombok.Getter; -import lombok.ToString; -@ToString(exclude = "componentsByName") public class Site { @Getter private final String name; diff --git a/src/main/java/com/refinedmods/refinedsites/playbook/GithubComponentFactory.java b/src/main/java/com/refinedmods/refinedsites/playbook/GithubComponentFactory.java index f7ffe1b..08dbab2 100644 --- a/src/main/java/com/refinedmods/refinedsites/playbook/GithubComponentFactory.java +++ b/src/main/java/com/refinedmods/refinedsites/playbook/GithubComponentFactory.java @@ -11,7 +11,6 @@ import java.util.stream.Stream; import com.vdurmont.semver4j.Semver; -import com.vdurmont.semver4j.SemverException; import lombok.extern.slf4j.Slf4j; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.errors.GitAPIException; @@ -38,28 +37,22 @@ class GithubComponentFactory implements ComponentFactory { log.warn("Ignoring tag {}", tagName); continue; } - final Semver version; - try { - version = new Semver(tagName.substring(1)); - } catch (SemverException e) { - log.warn("Invalid semver version detected {}", tagName.substring(1), e); - continue; - } + final Semver version = new Semver(tagName.substring(1)); if (version.isGreaterThanOrEqualTo(minVersion)) { log.info("Found valid version {}", version); validTags.add(new Tag( - tagName, - version.getValue(), - "v" + version.getValue(), - false + tagName, + version.getValue(), + "v" + version.getValue(), + false )); } } validTags.add(new Tag( - config.getSnapshotBranch(), - "snapshot", - "snapshot", - true + config.getSnapshotBranch(), + "snapshot", + "snapshot", + true )); } catch (IOException e) { throw new RuntimeException(e); @@ -74,23 +67,23 @@ public Stream getComponents() { log.info("Cloning version {} into {}", validTag, path); try { Git.cloneRepository() - .setURI(repo.getHtmlUrl().toString()) - .setDirectory(rootPath.resolve(path).toFile()) - .setBranch(validTag.tagName()) - .setDepth(1) - .call(); + .setURI(repo.getHtmlUrl().toString()) + .setDirectory(rootPath.resolve(path).toFile()) + .setBranch(validTag.tagName()) + .setDepth(1) + .call(); } catch (GitAPIException e) { throw new RuntimeException(e); } final LocalComponentFactory factory = new LocalComponentFactory( - rootPath.resolve(path), - name, - false, - new Version( - validTag.version, - validTag.friendlyVersion, - validTag.snapshot - ) + rootPath.resolve(path), + name, + false, + new Version( + validTag.version, + validTag.friendlyVersion, + validTag.snapshot + ) ); components.addAll(factory.getComponents().toList()); } diff --git a/src/main/java/com/refinedmods/refinedsites/playbook/SiteFactory.java b/src/main/java/com/refinedmods/refinedsites/playbook/SiteFactory.java index d26e799..226eac3 100644 --- a/src/main/java/com/refinedmods/refinedsites/playbook/SiteFactory.java +++ b/src/main/java/com/refinedmods/refinedsites/playbook/SiteFactory.java @@ -17,7 +17,6 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.Collections; -import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -27,6 +26,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.vdurmont.semver4j.Semver; import lombok.AllArgsConstructor; @AllArgsConstructor @@ -85,7 +85,11 @@ private Releases getReleases(final String componentName, final ReleaseConfig rel final List releases = sourceDataByName.entrySet() .stream() .map(entry -> new Release(entry.getKey(), entry.getValue())) - .sorted(Comparator.comparing(Release::getCreatedAt)) + .sorted((a, b) -> { + final Semver sa = new Semver(a.getName().substring(1)); + final Semver sb = new Semver(b.getName().substring(1)); + return sa.compareTo(sb); + }) .toList(); return new Releases(indexedAt, releases, componentName, Stats.of(sourceData)); } From 40dfae17b5eabbbee8889d8397597b176fb5af66 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sun, 24 Dec 2023 11:46:49 +0000 Subject: [PATCH 2/2] chore: prepare release v0.2.2 --- CHANGELOG.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb13461..6b96e4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,11 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [0.2.2] - 2023-12-24 + ### Fixed -- Fixed release version ordering. +- Fixed release version ordering. ## [0.2.1] - 2023-12-24 @@ -41,7 +43,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Initial release. -[Unreleased]: https://github.com/refinedmods/refinedsites/compare/v0.2.1...HEAD +[Unreleased]: https://github.com/refinedmods/refinedsites/compare/v0.2.2...HEAD + +[0.2.2]: https://github.com/refinedmods/refinedsites/compare/v0.2.1...v0.2.2 [0.2.1]: https://github.com/refinedmods/refinedsites/compare/v0.2.0...v0.2.1