fuzzyworld

north-star / commit

added commit info

f7854852fcc0b12b3af5db25c3dcca1fb800c9dc · Pavel Safronov · 2026-03-14 19:59:04 -0700 · parents 73446732d55d

added commit info
 .gitlab-ci.yml |  1 +
 src/app.js     | 11 ++++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8ed6471..1596d2c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -13,3 +13,4 @@ create-pages:
   script:
     - mkdir -p public
     - cp ./src/* ./public/ -R
+    - echo "export const GIT_COMMIT='${CI_COMMIT_SHORT_SHA}';" > public/commit.js
diff --git a/src/app.js b/src/app.js
index 3daec94..e05b4d9 100644
--- a/src/app.js
+++ b/src/app.js
@@ -28,6 +28,15 @@ const normalizeAngle = (angle) => ((angle % 360) + 360) % 360;
 const RENDER_INTERVAL_MS = 180;
 const LOCATION_SYNC_INTERVAL_MS = 3000;
 const HEADING_CORRECTION_DEG = 0;
+let GIT_COMMIT = 'local-dev';
+try {
+    const commitModule = await import('./commit.js');
+    if (typeof commitModule.GIT_COMMIT === 'string') {
+        GIT_COMMIT = commitModule.GIT_COMMIT;
+    }
+} catch {
+    // Local/dev environments may not have commit.js.
+}
 
 /**
  * @typedef {Object} Position
@@ -635,7 +644,7 @@ const render = () => {
     document.body.style.backgroundColor = selfParticipant.color;
 
     // output debug info
-    logDebug(`Name: ${selfParticipant.name} | Position: ${selfParticipant.position.lat.toFixed(1)}, ${selfParticipant.position.lon.toFixed(1)} | Heading: ${selfHeading.toFixed(2)}° | Real participants: ${participants.length}`);
+    logDebug(`Name: ${selfParticipant.name} | Position: ${selfParticipant.position.lat.toFixed(1)}, ${selfParticipant.position.lon.toFixed(1)} | Heading: ${selfHeading.toFixed(2)}° | Real participants: ${participants.length} | Commit: ${GIT_COMMIT}`);
 };
 
 await syncSelfParticipant();