Fetch Gerrit version dynamically in intro.html Avoid having a stale version number in the intro.html and fetch the current version dynamically using the /config/server/version. In case of errors, keep the v3.15 text by default. Change-Id: I1c99f23cfeebb2081fa7bf06818531d5e9a511f1
diff --git a/src/main/resources/static/intro.html b/src/main/resources/static/intro.html index f943b9b..7ce5686 100644 --- a/src/main/resources/static/intro.html +++ b/src/main/resources/static/intro.html
@@ -22,7 +22,7 @@ <section class="hero-section"> <div class="hero-header"> <img src="images/diffy-gerrit-code-review.png" alt="Gerrit Diffy" class="hero-image"> - <h1 class="hero-title">Welcome to<br>Gerrit v3.15</h1> + <h2 class="hero-title">Welcome to<br>Gerrit v<version id="gerrit-version">3.15</version></h2> </div> <p class="hero-intro-text"> @@ -106,5 +106,31 @@ </p> </footer> + <script> + document.addEventListener('DOMContentLoaded', () => { + fetch('/config/server/version') + .then(response => { + if (!response.ok) { + console.error('Error fetching Gerrit version: HTTP status ', response.status); + return ""; + } + return response.text(); + }) + .then(text => { + const lines = text.trim().split('\n').filter(line => line.length > 0); + if (lines.length > 1) { + const version = lines[lines.length - 1].replace(/"/g, ''); + const versionElement = document.getElementById('gerrit-version'); + if (versionElement) { + versionElement.textContent = version; + } + } + }) + .catch(error => { + console.error('Error fetching Gerrit version:', error); + }); + }); + </script> + </body> </html> \ No newline at end of file