KAFKA-1901; Added error handling when no file exists in .git/refs/heads.

guozhangwang  added .git/refs/heads/ file existence check.

Author: Manikumar reddy O <manikumar.reddy@gmail.com>

Reviewers: Ismael Juma, Guozhang Wang

Closes #209 from omkreddy/KAFKA-1901
This commit is contained in:
Manikumar reddy O 2016-01-06 12:48:47 -08:00 committed by Guozhang Wang
parent b098f677ae
commit 25fa39d5ef
1 changed files with 5 additions and 4 deletions

View File

@ -431,13 +431,14 @@ project(':clients') {
def headRef = file("../.git/HEAD").text
if (headRef.contains('ref: ')) {
headRef = headRef.replaceAll('ref: ', '').trim()
commitId = file("../.git/$headRef").text.trim().take(takeFromHash)
if (file("../.git/$headRef").exists()) {
commitId = file("../.git/$headRef").text.trim().take(takeFromHash)
}
} else {
commitId = headRef.trim().take(takeFromHash)
}
} else {
commitId
}
}
commitId
}
task createVersionFile(dependsOn: determineCommitId) {