You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by gh...@apache.org on 2023/10/23 16:47:27 UTC
[kafka] branch 3.4 updated: KAFKA-14767: Fix missing commitId build error after git gc (#13315)
This is an automated email from the ASF dual-hosted git repository.
gharris pushed a commit to branch 3.4
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/3.4 by this push:
new 7a3085ce69c KAFKA-14767: Fix missing commitId build error after git gc (#13315)
7a3085ce69c is described below
commit 7a3085ce69c7cfdae93a8ca7084bc1d6f983a113
Author: Greg Harris <gr...@aiven.io>
AuthorDate: Sun Oct 22 11:08:01 2023 -0700
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 <is...@juma.me.uk>
---
build.gradle | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/build.gradle b/build.gradle
index fc12fd2faf0..860892a8b7c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -113,6 +113,7 @@ ext {
throw new GradleException("Unexpected value for scalaOptimizerMode property. Expected one of $scalaOptimizerValues, but received: $userScalaOptimizerMode")
generatedDocsDir = new File("${project.rootDir}/docs/generated")
+ repo = file("$rootDir/.git").isDirectory() ? Grgit.open(currentDir: project.getRootDir()) : null
commitId = determineCommitId()
}
@@ -168,16 +169,8 @@ def determineCommitId() {
def takeFromHash = 16
if (project.hasProperty('commitId')) {
commitId.take(takeFromHash)
- } else if (file("$rootDir/.git/HEAD").exists()) {
- def headRef = file("$rootDir/.git/HEAD").text
- 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 if (repo != null) {
+ repo.head().id.take(takeFromHash)
} else {
"unknown"
}
@@ -185,7 +178,7 @@ def determineCommitId() {
apply from: file('wrapper.gradle')
-if (file('.git').exists()) {
+if (repo != null) {
rat {
verbose.set(true)
reportDir.set(project.file('build/rat'))
@@ -193,7 +186,6 @@ if (file('.git').exists()) {
// 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.
- def repo = Grgit.open(currentDir: project.getRootDir())
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
excludes.addAll([