alexeyinkin commented on code in PR #25610:
URL: https://github.com/apache/beam/pull/25610#discussion_r1128959040


##########
playground/backend/containers/git-functions.gradle:
##########
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * License); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ext.getGitCommitHash = () -> {
+   def stdout = new ByteArrayOutputStream()
+   exec {
+      executable('git')
+      args('rev-parse', 'HEAD')
+      standardOutput = stdout
+   }
+   return stdout.toString().trim()
+} as Closure<String>
+
+ext.getGitCommitTimestamp = () -> {
+   def stdout = new ByteArrayOutputStream()
+   exec {
+      executable('git')
+      args('show', '-s', '--format=%ct', 'HEAD')
+      standardOutput = stdout
+   }
+   return stdout.toString().trim()
+} as Closure<String>

Review Comment:
   We need this in 6 separate locations:
   - Building the frontend container.
   - Building the router container.
   - Building the 4 runners.
   
   The 5 backends may be similar but frontend and backend are still two rather 
distinct users of this. This motivates to do this in a single location like 
this because duplicating `git show -s --format=%ct HEAD` and `git rev-parse 
HEAD` 2-6 times is more confusing.
   
   Next, we cannot do this in Dockerfile because by the time it is built the 
directory is unaware of `.git`.
   
   This leads to the requirement of having the values before the 6 containers' 
builds start. And their builds are triggered from Gradle. So we cannot shorten 
this to `command $(git rev-parse HEAD)`, we would still have the whole `exec { 
... }` thing but in 12 locations.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to