chore: ReadmeGenerator does not generate correct version

This commit is contained in:
inotia00 2023-11-07 22:06:06 +09:00
parent bb47c3fe43
commit 750ef33b20
3 changed files with 6 additions and 35 deletions

View File

@ -11,13 +11,6 @@ repositories {
mavenLocal() mavenLocal()
google() google()
maven { url = uri("https://jitpack.io") } maven { url = uri("https://jitpack.io") }
// Required for FlexVer-Java
maven {
url = uri("https://repo.sleeping.town")
content {
includeGroup("com.unascribed")
}
}
} }
dependencies { dependencies {
@ -25,7 +18,6 @@ dependencies {
implementation(libs.smali) implementation(libs.smali)
// Used in JsonGenerator. // Used in JsonGenerator.
implementation(libs.gson) implementation(libs.gson)
implementation(libs.flexver)
} }
kotlin { kotlin {

View File

@ -2,10 +2,8 @@
revanced-patcher = "19.0.0" revanced-patcher = "19.0.0"
smali = "3.0.3" smali = "3.0.3"
gson = "2.10.1" gson = "2.10.1"
flexver = "1.1.1"
[libraries] [libraries]
revanced-patcher = { module = "app.revanced:revanced-patcher", version.ref = "revanced-patcher" } revanced-patcher = { module = "app.revanced:revanced-patcher", version.ref = "revanced-patcher" }
smali = { module = "com.android.tools.smali:smali", version.ref = "smali" } smali = { module = "com.android.tools.smali:smali", version.ref = "smali" }
gson = { module = "com.google.code.gson:gson", version.ref = "gson" } gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
flexver = { module = "com.unascribed:flexver-java", version.ref = "flexver" }

View File

@ -2,7 +2,6 @@ package app.revanced.meta
import app.revanced.patcher.PatchSet import app.revanced.patcher.PatchSet
import app.revanced.patcher.patch.Patch import app.revanced.patcher.patch.Patch
import com.unascribed.flexver.FlexVerComparator
import java.io.File import java.io.File
internal class ReadmeGenerator : PatchesFileGenerator { internal class ReadmeGenerator : PatchesFileGenerator {
@ -27,36 +26,18 @@ internal class ReadmeGenerator : PatchesFileGenerator {
.entries .entries
.sortedByDescending { it.value.size } .sortedByDescending { it.value.size }
.forEach { (`package`, patches) -> .forEach { (`package`, patches) ->
val supportVersions = buildMap {
patches.forEach { patch ->
patch.compatiblePackages?.single { compatiblePackage -> compatiblePackage.name == `package` }?.versions?.let {
it.forEach { version -> merge(version, 1, Integer::sum) }
}
}
}
val minVersion = supportVersions.let { commonMap ->
commonMap.maxByOrNull { it.value }?.value?.let {
commonMap.entries.filter { supported -> supported.value == it }
.minOfWith(FlexVerComparator::compare, Map.Entry<String, Int>::key)
} ?: "all"
}
val maxVersion = supportVersions.let { commonMap ->
commonMap.maxByOrNull { it.value }?.value?.let {
commonMap.entries.filter { supported -> supported.value == it }
.maxOfWith(FlexVerComparator::compare, Map.Entry<String, Int>::key)
} ?: "all"
}
output.apply { output.apply {
appendLine("### [\uD83D\uDCE6 `${`package`}`](https://play.google.com/store/apps/details?id=${`package`})") appendLine("### [\uD83D\uDCE6 `${`package`}`](https://play.google.com/store/apps/details?id=${`package`})")
appendLine("<details>\n") appendLine("<details>\n")
appendLine(TABLE_HEADER) appendLine(TABLE_HEADER)
patches.sortedBy { it.name }.forEach { patch -> patches.sortedBy { it.name }.forEach { patch ->
val supportedVersionArray =
patch.compatiblePackages?.single { it.name == `package` }?.versions
val supportedVersion = val supportedVersion =
if ( if (supportedVersionArray?.isNotEmpty() == true) {
patch.compatiblePackages?.single { it.name == `package` }?.versions?.isNotEmpty() == true val minVersion = supportedVersionArray.elementAt(0)
) { val maxVersion =
supportedVersionArray.elementAt(supportedVersionArray.size - 1)
if (minVersion == maxVersion) if (minVersion == maxVersion)
maxVersion maxVersion
else else