Skip to content

Commit

Permalink
build: always print unclean status when initializing git
Browse files Browse the repository at this point in the history
  • Loading branch information
Bixilon committed Feb 6, 2024
1 parent aa12de7 commit bef2f86
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ test:
reports:
junit: build/test-results/**/TEST-*.xml

# TODO: upload release in the publish step?
package:
stage: package
script:
Expand Down
14 changes: 8 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ tasks.test {
var git: Grgit? = null
var commit: Commit? = null


fun Commit.shortId() = id.substring(0, 10)

fun loadGit() {
val git: Grgit
try {
Expand All @@ -447,10 +450,12 @@ fun loadGit() {
stable = true
tag.name
} else {
commit.id.substring(0, 10)
commit.shortId()
}
if (!git.status().isClean) {
val status = git.status()
if (!status.isClean) {
nextVersion += "-dirty"
println(status)
}
if (project.version != nextVersion) {
project.version = nextVersion
Expand All @@ -466,13 +471,10 @@ val versionJsonTask = tasks.register("versionJson") {
doFirst {
fun generateGit(git: Grgit, commit: Commit): Map<String, Any> {
val status = git.status()
if (!status.isClean) {
println(status)
}
return mapOf(
"branch" to (System.getenv()["CI_COMMIT_BRANCH"] ?: git.branch.current().name),
"commit" to commit.id,
"commit_short" to commit.abbreviatedId,
"commit_short" to commit.shortId(),
"dirty" to !status.isClean,
)
}
Expand Down

0 comments on commit bef2f86

Please sign in to comment.