Skip to content

Commit e89c537

Browse files
committed
Update project
1 parent b1c4266 commit e89c537

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

app/build.gradle.kts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import org.apache.commons.io.output.ByteArrayOutputStream
2-
import java.nio.charset.Charset
1+
import java.nio.charset.StandardCharsets
32

43
plugins {
54
alias(libs.plugins.android.application)
@@ -8,16 +7,16 @@ plugins {
87
}
98

109
private val gitCommitsCount: Int by lazy {
11-
when {
12-
System.getProperty("os.name").contains("Windows", ignoreCase = true) -> 1
13-
else -> {
14-
val stdout = ByteArrayOutputStream()
15-
exec {
16-
commandLine("git", "rev-list", "--count", "HEAD")
17-
standardOutput = stdout
18-
}
19-
stdout.toString(Charset.defaultCharset()).trim().toInt()
10+
try {
11+
val isWindows = System.getProperty("os.name").contains("Windows", ignoreCase = true)
12+
val processBuilder = when {
13+
isWindows -> ProcessBuilder("cmd", "/c", "git", "rev-list", "--count", "HEAD")
14+
else -> ProcessBuilder("git", "rev-list", "--count", "HEAD")
2015
}
16+
processBuilder.redirectErrorStream(true)
17+
processBuilder.start().inputStream.bufferedReader(StandardCharsets.UTF_8).readLine().trim().toInt()
18+
} catch (_: Exception) {
19+
1
2120
}
2221
}
2322

0 commit comments

Comments
 (0)