kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ewe...@apache.org
Subject kafka git commit: MINOR: Use commitId property if set
Date Thu, 03 Aug 2017 22:31:19 GMT
Repository: kafka
Updated Branches:
  refs/heads/0.10.2 acfb9dba9 -> 0b6e38a2c


MINOR: Use commitId property if set

This allows a build system to set the correct commit ID when .git/HEAD would be wrong
if there are local commits for build purposes.

Author: Max Zheng <mzheng@confluent.io>

Reviewers: Ismael Juma <ismael@juma.me.uk>, Ewen Cheslack-Postava <ewen@confluent.io>

Closes #3606 from maxzheng/read-commit@trunk

(cherry picked from commit 613971f8d401e42f985e0942927348dcee640b75)
Signed-off-by: Ewen Cheslack-Postava <me@ewencp.org>


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/0b6e38a2
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/0b6e38a2
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/0b6e38a2

Branch: refs/heads/0.10.2
Commit: 0b6e38a2ced23f04908e9a65505f6e1b5020d6c9
Parents: acfb9db
Author: Max Zheng <mzheng@confluent.io>
Authored: Thu Aug 3 15:24:05 2017 -0700
Committer: Ewen Cheslack-Postava <me@ewencp.org>
Committed: Thu Aug 3 15:30:56 2017 -0700

----------------------------------------------------------------------
 README.md    |  1 +
 build.gradle | 14 +++++++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/0b6e38a2/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index d55098e..8163d8f 100644
--- a/README.md
+++ b/README.md
@@ -133,6 +133,7 @@ may not be dedicated to Kafka's build.
 
 The following options should be set with a `-D` switch, for example `./gradlew -Dorg.gradle.project.maxParallelForks=1
test`.
 
+* `commitId`: sets the build commit ID as .git/HEAD might not be correct if there are local
commits added for build purposes.
 * `org.gradle.project.mavenUrl`: sets the URL of the maven deployment repository (`file://path/to/repo`
can be used to point to a local repository).
 * `org.gradle.project.maxParallelForks`: limits the maximum number of processes for each
task.
 * `org.gradle.project.showStandardStreams`: shows standard out and standard error of the
test JVM(s) on the console.

http://git-wip-us.apache.org/repos/asf/kafka/blob/0b6e38a2/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 32ce14a..20a184c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -89,6 +89,8 @@ ext {
   userTestLoggingEvents = project.hasProperty("testLoggingEvents") ? Arrays.asList(testLoggingEvents.split(","))
: null
 
   generatedDocsDir = new File("${project.rootDir}/docs/generated")
+
+  commitId = project.hasProperty('commitId') ? commitId : null
 }
 
 apply from: "$rootDir/gradle/dependencies.gradle"
@@ -604,20 +606,22 @@ project(':clients') {
   }
 
   task determineCommitId {
-    ext.commitId = "unknown"
     def takeFromHash = 16
-    if (file("$rootDir/.git/HEAD").exists()) {
+    if (commitId) {
+      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()) {
-        commitId = file("$rootDir/.git/$headRef").text.trim().take(takeFromHash)
+          commitId = file("$rootDir/.git/$headRef").text.trim().take(takeFromHash)
         }
       } else {
         commitId = headRef.trim().take(takeFromHash)
       }
+    } else {
+      commitId = "unknown"
     }
-    commitId
   }
 
   task createVersionFile(dependsOn: determineCommitId) {
@@ -626,7 +630,7 @@ project(':clients') {
     outputs.upToDateWhen { false }
     doLast {
       def data = [
-        commitId: determineCommitId.commitId,
+        commitId: commitId,
         version: version,
       ]
 


Mime
View raw message