From 8b9a2ec94615f06e97fb142361ab4019a86b252b Mon Sep 17 00:00:00 2001
From: John Swinbank <john@swinbank.org>
Date: Fri, 21 Oct 2022 12:16:16 +0200
Subject: [PATCH] Insert version string on build

---
 package.json         | 3 ++-
 src/routes/Routes.js | 4 +++-
 src/utils/version.js | 3 +++
 3 files changed, 8 insertions(+), 2 deletions(-)
 create mode 100644 src/utils/version.js

diff --git a/package.json b/package.json
index 73bcdb1..6fd0ca7 100644
--- a/package.json
+++ b/package.json
@@ -25,7 +25,8 @@
     "start": "react-scripts start",
     "build": "react-scripts build",
     "test": "react-scripts test",
-    "eject": "react-scripts eject"
+    "eject": "react-scripts eject",
+    "prebuild": "git log -1 --format=\"export const COMMIT_DATE=\\\"%cd\\\"%nexport const COMMIT_URL=\\\"https://git.astron.nl/astron-sdc/esap-gui/-/tree/%H\\\"\" > src/utils/version.js"
   },
   "eslintConfig": {
     "extends": "react-app"
diff --git a/src/routes/Routes.js b/src/routes/Routes.js
index e73f452..fcf3c49 100644
--- a/src/routes/Routes.js
+++ b/src/routes/Routes.js
@@ -30,6 +30,8 @@ import AladinAdvancedPage from '../components/services/aladin/AladinAdvancedPage
 import Jobs from "../components/services/Jobs";
 import {createBrowserHistory} from "history"
 
+import { COMMIT_DATE, COMMIT_URL } from "../utils/version";
+
 export default function Routes() {
     const history = createBrowserHistory();
     const { navbar, handleLogin, handleLogout, handleError } = useContext(GlobalContext);
@@ -118,7 +120,7 @@ export default function Routes() {
 
         </Switch>
 
-      <footer><small>esap-gui version 21 jan 2022 - 10:00</small></footer>
+      <footer><small><a href={COMMIT_URL}>ESAP-GUI version {COMMIT_DATE}</a></small></footer>
     </Router>
   );
 }
diff --git a/src/utils/version.js b/src/utils/version.js
new file mode 100644
index 0000000..9472bee
--- /dev/null
+++ b/src/utils/version.js
@@ -0,0 +1,3 @@
+// Autogenerated on build; do not edit
+export const COMMIT_DATE="(Development Version)"
+export const COMMIT_URL="https://git.astron.nl/astron-sdc/esap-gui"
-- 
GitLab