From 65f61de912aee800b737a5b576a57f313e8451d3 Mon Sep 17 00:00:00 2001
From: Marshall Quander <marshall@quander.me>
Date: Tue, 17 Jul 2018 16:27:24 -0700
Subject: [PATCH] Print out Hubs version and commit in console

---
 Jenkinsfile                   |  2 +-
 scripts/hab-build-and-push.sh |  4 +++-
 src/hub.js                    | 15 ++++++++++-----
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 8844d357d..5951a3a73 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -37,7 +37,7 @@ pipeline {
           def smokeURL = env.SMOKE_URL
           def slackURL = env.SLACK_URL
 
-          def habCommand = "sudo /usr/bin/hab-docker-studio -k mozillareality run /bin/bash scripts/hab-build-and-push.sh ${baseAssetsPath} ${assetBundleServer} ${targetS3Url} ${env.BUILD_NUMBER}"
+          def habCommand = "sudo /usr/bin/hab-docker-studio -k mozillareality run /bin/bash scripts/hab-build-and-push.sh ${baseAssetsPath} ${assetBundleServer} ${targetS3Url} ${env.BUILD_NUMBER} ${env.GIT_COMMIT}"
           sh "/usr/bin/script --return -c ${shellString(habCommand)} /dev/null"
 
           def gitMessage = sh(returnStdout: true, script: "git log -n 1 --pretty=format:'[%an] %s'").trim()
diff --git a/scripts/hab-build-and-push.sh b/scripts/hab-build-and-push.sh
index 2f04c0a26..f890d0e05 100755
--- a/scripts/hab-build-and-push.sh
+++ b/scripts/hab-build-and-push.sh
@@ -3,7 +3,9 @@
 export BASE_ASSETS_PATH=$1
 export ASSET_BUNDLE_SERVER=$2
 export TARGET_S3_URL=$3
-export BUILD_VERSION=$4
+export BUILD_NUMBER=$4
+export GIT_COMMIT=$5
+export BUILD_VERSION="${BUILD_NUMBER} (${GIT_COMMIT})"
 
 # To build + push to S3 run:
 # hab studio run "bash scripts/hab-build-and-push.sh"
diff --git a/src/hub.js b/src/hub.js
index 06c38f518..51419d8d6 100644
--- a/src/hub.js
+++ b/src/hub.js
@@ -1,3 +1,5 @@
+console.log(`Hubs version: ${process.env.BUILD_VERSION || "?"}`);
+
 import "./assets/stylesheets/hub.scss";
 import queryString from "query-string";
 
@@ -431,11 +433,14 @@ const onReady = async () => {
     return;
   }
 
-  if (qs.required_version && qs.required_version !== process.env.BUILD_VERSION) {
-    remountUI({ roomUnavailableReason: "version_mismatch" });
-    setTimeout(() => document.location.reload(), 5000);
-    exitScene();
-    return;
+  if (qs.required_version && process.env.BUILD_VERSION) {
+    const buildNumber = process.env.BUILD_VERSION.split(" ", 1)[0]; // e.g. "123 (abcd5678)"
+    if (qs.required_version !== buildNumber) {
+      remountUI({ roomUnavailableReason: "version_mismatch" });
+      setTimeout(() => document.location.reload(), 5000);
+      exitScene();
+      return;
+    }
   }
 
   getAvailableVREntryTypes().then(availableVREntryTypes => {
-- 
GitLab