Skip to content

Commit

Permalink
add comments to build.gradle regarding use of git
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Nov 1, 2022
1 parent cbe7f0c commit 04be4fd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,21 @@ task clean(type: Delete) {
delete rootProject.buildDir
}

// Use git revision counter as a version code.
static def gitVersionCode() {
// If you are not compiling in a git directory and getting an error like
// [A problem occurred evaluating root project 'master'. For input string: ""]
// then just return your manually assigned error code like this:
// return 12345
def process = "git rev-list --count HEAD".execute()
return process.text.toInteger()
}

// Use current git tag as a version name.
// For example, if the git tag is 'v0.20.0-rc1' then the version name will be '0.20.0-rc1'.
static def gitVersionName() {
// If you are not compiling in a git directory, you should manually assign version name:
// return "MyVersionName"
def process = "git describe --tags".execute()
// Remove trailing CR and remove leading 'v' as in 'v1.2.3'
return process.text.trim().substring(1)
Expand Down

0 comments on commit 04be4fd

Please sign in to comment.