Skip to content

Commit

Permalink
Merge pull request #21 from swiftzer/before-v2
Browse files Browse the repository at this point in the history
Minor changes before v2
  • Loading branch information
ericksli authored Mar 2, 2024
2 parents 7cb6408 + dcc4215 commit 05830c7
Show file tree
Hide file tree
Showing 12 changed files with 471 additions and 431 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
commit-message:
prefix: build
- package-ecosystem: gradle
directory: /
schedule:
interval: weekly
commit-message:
prefix: build
8 changes: 5 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ version = buildString {

kotlin {
explicitApi()

jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
Expand All @@ -42,6 +43,7 @@ kotlin {
useJUnitPlatform()
}
}

js(IR) {
browser()
nodejs()
Expand Down Expand Up @@ -175,9 +177,9 @@ publishing {
}

tasks.register("detektAll") {
group = "verification"
dependsOn(tasks.withType<Detekt>())
}

fun getProperty(propertyName: String): String? {
return System.getenv()[propertyName] ?: publishingProperties.getProperty(propertyName)
}
fun getProperty(propertyName: String): String? =
providers.environmentVariable(propertyName).orNull ?: publishingProperties.getProperty(propertyName)
2 changes: 0 additions & 2 deletions config/detekt/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -780,5 +780,3 @@ style:
ignoreLateinitVar: false
WildcardImport:
active: true
excludeImports:
- 'java.util.*'
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ kotest-multiplatform = { id = "io.kotest.multiplatform", version.ref = "kotest"
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlinx-binaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "kotlinxBinaryCompatibilityValidator" }
kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
6 changes: 3 additions & 3 deletions src/commonMain/kotlin/net/swiftzer/semver/SemVer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ public data class SemVer(
@Suppress("DestructuringDeclarationWithTooManyEntries")
public fun parse(version: String): SemVer {
val (major, minor, patch, preRelease, buildMetadata) = (
FullPattern.matchEntire(version)
?: throw IllegalArgumentException("Invalid version string [$version]")
).destructured
FullPattern.matchEntire(version)
?: throw IllegalArgumentException("Invalid version string [$version]")
).destructured
return SemVer(
major = major.toInt(),
minor = minor.toInt(),
Expand Down
109 changes: 56 additions & 53 deletions src/commonTest/kotlin/net/swiftzer/semver/SemVerParseFailTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,59 @@ import io.kotest.core.spec.style.FunSpec
import io.kotest.datatest.withData
import io.kotest.matchers.nulls.shouldBeNull

class SemVerParseFailTest : FunSpec({
withData(
nameFn = { "fail case [$it]" },
ts = sequenceOf(
"v1.2.3",
" 1.2.3",
"1.2.3 ",
"1",
"a",
"1.2",
"1.2.3-0123",
"1.2.3-0123.0123",
"1.1.2+.123",
"+invalid",
"-invalid",
"-invalid+invalid",
"-invalid.01",
"alpha",
"alpha.beta",
"alpha.beta.1",
"alpha.1",
"alpha+beta",
"alpha_beta",
"alpha.",
"alpha..",
"beta",
"1.0.0-alpha_beta",
"-alpha.",
"1.0.0-alpha..",
"1.0.0-alpha..1",
"1.0.0-alpha...1",
"1.0.0-alpha....1",
"1.0.0-alpha.....1",
"1.0.0-alpha......1",
"1.0.0-alpha.......1",
"01.1.1",
"1.01.1",
"1.1.01",
"1.2.3.DEV",
"1.2-SNAPSHOT",
"1.2.31.2.3----RC-SNAPSHOT.12.09.1--..12+788",
"1.2-RC-SNAPSHOT",
"-1.0.3-gamma+b7718",
"+justmeta",
"9.8.7+meta+meta",
"9.8.7-whatever+meta+meta",
"99999999999999999999999.999999999999999999.99999999999999999----RC-SNAPSHOT.12.09.1--------------------------------..12",
),
) {
shouldThrow<IllegalArgumentException> { SemVer.parse(it) }
SemVer.parseOrNull(it).shouldBeNull()
}
})
@Suppress("MaxLineLength")
class SemVerParseFailTest : FunSpec(
{
withData(
nameFn = { "fail case [$it]" },
ts = sequenceOf(
"v1.2.3",
" 1.2.3",
"1.2.3 ",
"1",
"a",
"1.2",
"1.2.3-0123",
"1.2.3-0123.0123",
"1.1.2+.123",
"+invalid",
"-invalid",
"-invalid+invalid",
"-invalid.01",
"alpha",
"alpha.beta",
"alpha.beta.1",
"alpha.1",
"alpha+beta",
"alpha_beta",
"alpha.",
"alpha..",
"beta",
"1.0.0-alpha_beta",
"-alpha.",
"1.0.0-alpha..",
"1.0.0-alpha..1",
"1.0.0-alpha...1",
"1.0.0-alpha....1",
"1.0.0-alpha.....1",
"1.0.0-alpha......1",
"1.0.0-alpha.......1",
"01.1.1",
"1.01.1",
"1.1.01",
"1.2.3.DEV",
"1.2-SNAPSHOT",
"1.2.31.2.3----RC-SNAPSHOT.12.09.1--..12+788",
"1.2-RC-SNAPSHOT",
"-1.0.3-gamma+b7718",
"+justmeta",
"9.8.7+meta+meta",
"9.8.7-whatever+meta+meta",
"99999999999999999999999.999999999999999999.99999999999999999----RC-SNAPSHOT.12.09.1--------------------------------..12",
),
) {
shouldThrow<IllegalArgumentException> { SemVer.parse(it) }
SemVer.parseOrNull(it).shouldBeNull()
}
},
)
Loading

0 comments on commit 05830c7

Please sign in to comment.