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:24:10 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 13deb84dc -> 613971f8d


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


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

Branch: refs/heads/trunk
Commit: 613971f8d401e42f985e0942927348dcee640b75
Parents: 13deb84
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:24:05 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/613971f8/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index c224ad4..5b4e654 100644
--- a/README.md
+++ b/README.md
@@ -164,6 +164,7 @@ directories.  Use -PxmlFindBugsReport=true to generate an XML report instead
of
 
 The following options should be set with a `-P` switch, for example `./gradlew -PmaxParallelForks=1
test`.
 
+* `commitId`: sets the build commit ID as .git/HEAD might not be correct if there are local
commits added for build purposes.
 * `mavenUrl`: sets the URL of the maven deployment repository (`file://path/to/repo` can
be used to point to a local repository).
 * `maxParallelForks`: limits the maximum number of processes for each task.
 * `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/613971f8/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index a1cb545..53c0e8d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -98,6 +98,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: file('wrapper.gradle')
@@ -751,20 +753,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) {
@@ -773,7 +777,7 @@ project(':clients') {
     outputs.upToDateWhen { false }
     doLast {
       def data = [
-        commitId: determineCommitId.commitId,
+        commitId: commitId,
         version: version,
       ]
 


Mime
View raw message