mirror of https://github.com/apache/kafka.git
KAFKA-14767: Fix missing commitId build error after git gc (#13315)
git gc moves commit hashes from individual .git/refs/heads/ to .git/packed-refs which is not read by the determineCommitId function. Replace the existing lookup within the .git directory with a GrGit lookup that handles packed and unpacked refs transparently. Reviewers: Ismael Juma <ismael@juma.me.uk>
This commit is contained in:
parent
e569b5d2c8
commit
af228ca84f
16
build.gradle
16
build.gradle
|
@ -106,6 +106,7 @@ ext {
|
||||||
throw new GradleException("Unexpected value for scalaOptimizerMode property. Expected one of $scalaOptimizerValues, but received: $userScalaOptimizerMode")
|
throw new GradleException("Unexpected value for scalaOptimizerMode property. Expected one of $scalaOptimizerValues, but received: $userScalaOptimizerMode")
|
||||||
|
|
||||||
generatedDocsDir = new File("${project.rootDir}/docs/generated")
|
generatedDocsDir = new File("${project.rootDir}/docs/generated")
|
||||||
|
repo = file("$rootDir/.git").isDirectory() ? Grgit.open(currentDir: project.getRootDir()) : null
|
||||||
|
|
||||||
commitId = determineCommitId()
|
commitId = determineCommitId()
|
||||||
}
|
}
|
||||||
|
@ -161,16 +162,8 @@ def determineCommitId() {
|
||||||
def takeFromHash = 16
|
def takeFromHash = 16
|
||||||
if (project.hasProperty('commitId')) {
|
if (project.hasProperty('commitId')) {
|
||||||
commitId.take(takeFromHash)
|
commitId.take(takeFromHash)
|
||||||
} else if (file("$rootDir/.git/HEAD").exists()) {
|
} else if (repo != null) {
|
||||||
def headRef = file("$rootDir/.git/HEAD").text
|
repo.head().id.take(takeFromHash)
|
||||||
if (headRef.contains('ref: ')) {
|
|
||||||
headRef = headRef.replaceAll('ref: ', '').trim()
|
|
||||||
if (file("$rootDir/.git/$headRef").exists()) {
|
|
||||||
file("$rootDir/.git/$headRef").text.trim().take(takeFromHash)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
headRef.trim().take(takeFromHash)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
"unknown"
|
"unknown"
|
||||||
}
|
}
|
||||||
|
@ -178,7 +171,7 @@ def determineCommitId() {
|
||||||
|
|
||||||
apply from: file('wrapper.gradle')
|
apply from: file('wrapper.gradle')
|
||||||
|
|
||||||
if (file('.git').exists()) {
|
if (repo != null) {
|
||||||
rat {
|
rat {
|
||||||
dependsOn subprojects.collect {
|
dependsOn subprojects.collect {
|
||||||
it.tasks.matching {
|
it.tasks.matching {
|
||||||
|
@ -192,7 +185,6 @@ if (file('.git').exists()) {
|
||||||
|
|
||||||
// Exclude everything under the directory that git should be ignoring via .gitignore or that isn't checked in. These
|
// Exclude everything under the directory that git should be ignoring via .gitignore or that isn't checked in. These
|
||||||
// restrict us only to files that are checked in or are staged.
|
// restrict us only to files that are checked in or are staged.
|
||||||
def repo = Grgit.open(currentDir: project.getRootDir())
|
|
||||||
excludes = new ArrayList<String>(repo.clean(ignore: false, directories: true, dryRun: true))
|
excludes = new ArrayList<String>(repo.clean(ignore: false, directories: true, dryRun: true))
|
||||||
// And some of the files that we have checked in should also be excluded from this check
|
// And some of the files that we have checked in should also be excluded from this check
|
||||||
excludes.addAll([
|
excludes.addAll([
|
||||||
|
|
Loading…
Reference in New Issue