Skip to content

Commit

Permalink
Fix up versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
romanowski committed Sep 11, 2020
1 parent 1a74cc4 commit 1fc41d6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ fun String.run(): String? {
}
}

val ciGeneratedFiles = listOf("settings.xml")

fun getVersion(): String {
val base = "git describe --tags --exact-match".run() ?: "git describe --tags".run() ?: "0.1.0-SNAPSHOT"

val statusStr = "git status --porcelain".run()?.let { if (it.trim().length > 2) "-SNAPSHOT" else "" } ?: "-SNAPSHOT"
val v = base + statusStr
val changedFiles = "git status --porcelain".run()?.lines()
?.filterNot { line -> line.isEmpty() || ciGeneratedFiles.find { file -> line.endsWith(" $file") } != null }

val statusStr = changedFiles?.let { if (it.isEmpty()) "" else "-SNAPSHOT" } ?: "-SNAPSHOT"
val v = base.removePrefix("v") + statusStr
println("Using $v version.")
return v
}
Expand Down

0 comments on commit 1fc41d6

Please sign in to comment.