From a54c464522fa2a6a2d2525c8cb0ec961c2cc771c Mon Sep 17 00:00:00 2001 From: rstular Date: Mon, 8 May 2023 01:43:06 +0200 Subject: [PATCH] fix(readme-generator): attempt sorting versions with `FlexVer` (#2059) Co-authored-by: oSumAtrIX --- build.gradle.kts | 9 +++++++++ src/main/kotlin/app/revanced/meta/ReadmeGenerator.kt | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 13547e1939..e7a5e6dc08 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,6 +17,13 @@ repositories { password = githubPassword } } + // Required for FlexVer-Java + maven { + url = uri("https://repo.sleeping.town") + content { + includeGroup("com.unascribed") + } + } } dependencies { @@ -24,6 +31,8 @@ dependencies { implementation("app.revanced:multidexlib2:2.5.3-a3836654") // Required for meta implementation("com.google.code.gson:gson:2.10.1") + // Required for FlexVer-Java + implementation("com.unascribed:flexver-java:1.0.2") } kotlin { diff --git a/src/main/kotlin/app/revanced/meta/ReadmeGenerator.kt b/src/main/kotlin/app/revanced/meta/ReadmeGenerator.kt index 530ca0500d..e8a951eace 100644 --- a/src/main/kotlin/app/revanced/meta/ReadmeGenerator.kt +++ b/src/main/kotlin/app/revanced/meta/ReadmeGenerator.kt @@ -5,6 +5,7 @@ import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages import app.revanced.patcher.extensions.PatchExtensions.description import app.revanced.patcher.extensions.PatchExtensions.patchName import app.revanced.patcher.patch.Patch +import com.unascribed.flexver.FlexVerComparator import java.io.File internal class ReadmeGenerator : PatchesFileGenerator { @@ -37,9 +38,8 @@ internal class ReadmeGenerator : PatchesFileGenerator { } }.let { commonMap -> commonMap.maxByOrNull { it.value }?.value?.let { - // This is not foolproof, because for example v1.0.0-dev.0 will be returned instead of v1.0.0-release. - // Unfortunately this can not be solved easily because versioning can be complex. - commonMap.entries.filter { mostCommon -> mostCommon.value == it }.maxBy { it.key }.key + commonMap.entries.filter { mostCommon -> mostCommon.value == it } + .maxOfWith(FlexVerComparator::compare, Map.Entry::key) } ?: "all" }