Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,7 @@ fun Parameters.parseRequest(extractVersion: Boolean): BindingsServerRequest? {
.drop(1)
.joinToString("/")
.takeUnless { it.isBlank() }
val version =
if (extractVersion) {
val versionPart = this["version"]!!
if (significantVersion == COMMIT_LENIENT) {
val versionParts = versionPart.split("__")
if (versionParts.size < 2) {
return null
}
versionParts[1]
} else {
versionPart
}
} else {
"irrelevant"
}
val comment =
if ((significantVersion == COMMIT_LENIENT) && extractVersion) this["version"]!!.split("__")[0] else null
val versionForTypings = if (extractVersion) this["version"]!!.split("__")[0] else "irrelevant"
val parsedVersion = parseVersion(extractVersion, significantVersion)

return BindingsServerRequest(
rawName = this["name"]!!,
Expand All @@ -57,11 +40,47 @@ fun Parameters.parseRequest(extractVersion: Boolean): BindingsServerRequest? {
ActionCoords(
owner = owner,
name = name,
version = version,
versionForTypings = versionForTypings,
version = parsedVersion.version ?: return null,
versionForTypings = parsedVersion.versionForTypings!!,
significantVersion = significantVersion,
path = path,
comment = comment,
comment = parsedVersion.comment,
),
)
}

private fun Parameters.parseVersion(
extractVersion: Boolean,
significantVersion: SignificantVersion,
): ParsedVersion =
if (extractVersion) {
val versionPart = this["version"]!!
val (version, comment) =
if (significantVersion == COMMIT_LENIENT) {
val versionParts = versionPart.split("__", limit = 2)
if (versionParts.size == 1) {
null to null
} else {
versionParts[1] to versionParts[0]
}
} else {
versionPart to null
}
ParsedVersion(
version = version,
comment = comment,
versionForTypings = comment ?: version,
)
} else {
ParsedVersion(
version = "irrelevant",
comment = null,
versionForTypings = "irrelevant",
)
}

private data class ParsedVersion(
val version: String?,
val comment: String?,
val versionForTypings: String?,
)
Loading