Skip to content

Commit

Permalink
Fix version code calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed Nov 8, 2020
1 parent a2ebb0c commit 4dc51e7
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions buildSrc/src/main/kotlin/VersionUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ fun Project.getVersionName(fallback: String = "0.0.0-dev.1"): String? {
* Get the version code for a given semantic version.
* Does not validate the input and thus will throw an exception when parts are missing.
*
* The pre-release part ("-rc.1", "-beta.1" etc.) defaults to 99
* The pre-release part ("-rc.1", "-beta.1" etc.) defaults to 99 when not specified.
*
* Sample output:
* MA.MI.PA-PR -> MAMIPAPR
* 0.0.0 -> 99
* 1.1.1 -> 1010199
* 0.7.0 -> 70099
* 99.99.99 -> 99999999
* 2.0.0-rc.3 -> 2000003
* 2.0.0 -> 2000099
* 99.99.99-rc.1 -> 99999901
* MA.MI.PA-PR > MA MI PA PR
* 0.0.0-dev.1 > 1
* 0.0.0 > 99
* 1.1.1 > 1 01 01 99
* 0.7.0 > 7 00 99
* 99.99.99 > 99 99 99 99
* 2.0.0-rc.3 > 2 00 00 03
* 2.0.0 > 2 00 00 99
* 99.99.99-rc.1 > 99 99 99 01
*/
fun getVersionCode(versionName: String): Int? {
// Split to core and pre release parts with a default for pre release (null)
Expand Down

0 comments on commit 4dc51e7

Please sign in to comment.