Skip to content

Commit

Permalink
Merge pull request #200 from NordicSemiconductor/fix/invalidVersion
Browse files Browse the repository at this point in the history
Fix: count versions as number of commits in current branch
  • Loading branch information
sylwester-zielinski authored Oct 17, 2023
2 parents c253411 + a7ae49b commit 4bfd07f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ nordic-mcumgr = "1.7.2"
nordic-scanner = "1.6.0"
nordic-common = "1.8.4"
nordic-memfault = "1.0.2"
nordicPlugins = "1.9.5"
nordicPlugins = "1.9.13"
dokkaPlugin = "1.9.10"
googleServicesPlugins = "4.3.15"
firebaseCrashlyticsPlugins = "2.9.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fun Project.getVersionCodeFromTags(): Int {
val code = ByteArrayOutputStream()
try {
exec {
commandLine("git", "rev-list", "--all", "--count")
commandLine("git", "rev-list", "--count", "HEAD")
standardOutput = code
}
} catch (e: Exception) {
Expand All @@ -56,8 +56,10 @@ fun Project.getVersionCodeFromTags(): Int {
val now = ZonedDateTime.now(ZoneId.of("UTC"))
val year = now.year % 100
val month = String.format("%02d", now.monthValue)
val revisions = code.toString().trim()
return "$year$month$revisions".toInt()
val day = String.format("%02d", now.dayOfMonth)
val revisions = String.format("%02d", code.toString().trim().toInt()%100)
val version = "$year$month$day$revisions".toInt()
return version
}

/**
Expand Down

0 comments on commit 4bfd07f

Please sign in to comment.