Skip to content

Commit

Permalink
Migrate to jgit
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanGIG committed Dec 25, 2023
1 parent 00ab28e commit 9c81f0f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
12 changes: 4 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-parcelize'
id 'org.lsposed.lsplugin.jgit'
}

//https://gist.github.com/paramsen/4a92c9230d799caeb3b90897da27a80c
static def generateVersionCode() {
def result = "git rev-list HEAD --count".execute().text.trim() //unix
if(result.empty) result = "PowerShell -Command git rev-list HEAD --count".execute().text.trim() //windows
if(result.empty) throw new RuntimeException("Could not generate versioncode on this platform? Cmd output: ${result.text}")
return result.toInteger()
}
var repo = jgit.repo(true)
var commitCount = (repo?.commitCount("refs/remotes/origin/master") ?: 1)

android {
compileSdk 34
Expand All @@ -20,7 +16,7 @@ android {
applicationId "com.dumper.android"
minSdk 21
targetSdk 34
versionCode generateVersionCode()
versionCode commitCount
versionName "0.0.7"
}

Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:8.1.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20"
classpath "org.lsposed.lsplugin:jgit:1.1"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down

0 comments on commit 9c81f0f

Please sign in to comment.