Skip to content

Commit

Permalink
fix: 修复版本号匹配
Browse files Browse the repository at this point in the history
  • Loading branch information
xz-dev committed Nov 3, 2020
1 parent 979f582 commit a7598ca
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ android {
applicationId "net.xzos.upgradeall"
minSdkVersion 21
targetSdkVersion 30
versionCode 51
versionName "0.1.4.24"
versionCode 52
versionName "0.1.5"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
kapt {
arguments {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ object AppValue {
const val default_cloud_rules_hub_url = "FromUpdateServer"
const val def_update_server_url = "update-server.xzos.net:5255"
val git_url_arg_regex = "(%.*?)\\w*".toRegex()
val version_number_match_regex = "(\\d+(\\.\\d+)*)(([.|\\-|+|_| ]|[0-9A-Za-z])*)".toRegex()
val version_number_strict_match_regex = "\\d+(\\.\\d+)+([.|\\-|+|_| ]*[A-Za-z0-9]+)*".toRegex()
val version_number_match_regex = "\\d+(\\.\\d+)*([.|\\-|+|_| ]*[A-Za-z0-9]+)*".toRegex()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.xzos.upgradeall.core.data_manager.utils

import net.xzos.upgradeall.core.data.config.AppValue
import net.xzos.upgradeall.core.data.config.AppValue.version_number_match_regex
import net.xzos.upgradeall.core.data.config.AppValue.version_number_strict_match_regex
import net.xzos.upgradeall.core.data.json.nongson.ObjectTag
import org.apache.maven.artifact.versioning.DefaultArtifactVersion

Expand All @@ -14,8 +15,8 @@ object VersioningUtils {

fun matchVersioningString(versionString: CharSequence?): String? {
return if (versionString != null) {
val regex = AppValue.version_number_match_regex
regex.find(versionString)?.value?.trim()
(version_number_strict_match_regex.find(versionString)
?: version_number_match_regex.find(versionString))?.value
} else null
}

Expand All @@ -24,7 +25,7 @@ object VersioningUtils {
* 若,前者比后者大,则返回 true
* 若,版本号不是语义化版本号,返回 NULL
*/
internal fun compareVersionNumber(versionNumber0: String?, versionNumber1: String?): Boolean? {
fun compareVersionNumber(versionNumber0: String?, versionNumber1: String?): Boolean? {
// 检查强制忽略版本号
if (versionNumber0 == FOREVER_IGNORE) return true
if (versionNumber1 == FOREVER_IGNORE) return false
Expand Down

0 comments on commit a7598ca

Please sign in to comment.