mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-22 20:32:05 +01:00
gradle.build: ensure 'git' command is run in project dir
This commit is contained in:
parent
b82b94a652
commit
686f017864
1 changed files with 7 additions and 6 deletions
13
build.gradle
13
build.gradle
|
@ -69,14 +69,14 @@ allprojects {
|
||||||
if (isSnapshot) {
|
if (isSnapshot) {
|
||||||
version = version + '-SNAPSHOT'
|
version = version + '-SNAPSHOT'
|
||||||
}
|
}
|
||||||
|
def projectDirFile = new File("$projectDir")
|
||||||
if (!project.ext.isSnapshot && !'git describe --exact-match HEAD'.execute().text.trim().equals(ext.shortVersion)) {
|
if (!project.ext.isSnapshot && !'git describe --exact-match HEAD'.execute(null, projectDirFile).text.trim().equals(ext.shortVersion)) {
|
||||||
throw new InvalidUserDataException('Untagged version detected! Please tag every release.')
|
throw new InvalidUserDataException('Untagged version detected! Please tag every release.')
|
||||||
}
|
}
|
||||||
if (!version.endsWith('-SNAPSHOT') && version != 'git tag --points-at HEAD'.execute().text.trim()) {
|
if (!version.endsWith('-SNAPSHOT') && version != 'git tag --points-at HEAD'.execute(null, projectDirFile).text.trim()) {
|
||||||
throw new InvalidUserDataException(
|
throw new InvalidUserDataException(
|
||||||
'Tag mismatch detected, version is ' + version + ' but should be ' +
|
'Tag mismatch detected, version is ' + version + ' but should be ' +
|
||||||
'git tag --points-at HEAD'.execute().text.trim())
|
'git tag --points-at HEAD'.execute(null, projectDirFile).text.trim())
|
||||||
}
|
}
|
||||||
|
|
||||||
jacoco {
|
jacoco {
|
||||||
|
@ -189,16 +189,17 @@ def getAndroidHome() {
|
||||||
}
|
}
|
||||||
|
|
||||||
def getGitCommit() {
|
def getGitCommit() {
|
||||||
|
def projectDirFile = new File("$projectDir")
|
||||||
def dotGit = new File("$projectDir/.git")
|
def dotGit = new File("$projectDir/.git")
|
||||||
if (!dotGit.isDirectory()) return 'non-git build'
|
if (!dotGit.isDirectory()) return 'non-git build'
|
||||||
|
|
||||||
def cmd = 'git describe --always --tags --dirty=+'
|
def cmd = 'git describe --always --tags --dirty=+'
|
||||||
def proc = cmd.execute()
|
def proc = cmd.execute(null, projectDirFile)
|
||||||
def gitCommit = proc.text.trim()
|
def gitCommit = proc.text.trim()
|
||||||
assert !gitCommit.isEmpty()
|
assert !gitCommit.isEmpty()
|
||||||
|
|
||||||
def srCmd = 'git symbolic-ref --short HEAD'
|
def srCmd = 'git symbolic-ref --short HEAD'
|
||||||
def srProc = srCmd.execute()
|
def srProc = srCmd.execute(null, projectDirFile)
|
||||||
srProc.waitForOrKill(10 * 1000)
|
srProc.waitForOrKill(10 * 1000)
|
||||||
if (srProc.exitValue() == 0) {
|
if (srProc.exitValue() == 0) {
|
||||||
// Only add the information if the git command was
|
// Only add the information if the git command was
|
||||||
|
|
Loading…
Reference in a new issue