Browse Source

Add recuperation of the current version from git if available (#731)

* Add recuperation of the current version from git if available
* Include version when auto-reporting an error
Teromene 5 years ago
parent
commit
da6b98851c
4 changed files with 30 additions and 2 deletions
  1. 2 1
      index.php
  2. 19 0
      lib/Configuration.php
  3. 4 1
      lib/Exceptions.php
  4. 5 0
      static/style.css

+ 2 - 1
index.php

@@ -253,7 +253,8 @@ EOD;
 		echo $inactiveBridges;
 	?>
 	<section class="footer">
-		<a href="https://github.com/RSS-Bridge/rss-bridge">RSS-Bridge 2018-06-10 ~ Public Domain</a><br />
+		<a href="https://github.com/RSS-Bridge/rss-bridge">RSS-Bridge ~ Public Domain</a><br />
+		<p class="version"> <?= Configuration::getVersion() ?> </p>
 		<?= $activeFoundBridgeCount; ?>/<?= count($bridgeList) ?> active bridges. <br />
 		<?php
 			if($activeFoundBridgeCount !== count($bridgeList)) {

+ 19 - 0
lib/Configuration.php

@@ -1,6 +1,8 @@
 <?php
 class Configuration {
 
+	public static $VERSION = "2018-06-10";
+
 	public static $config = null;
 
 	public static function verifyInstallation() {
@@ -102,4 +104,21 @@ class Configuration {
 
 	}
 
+	public static function getVersion() {
+
+		$headFile = '.git/HEAD';
+
+		if(file_exists($headFile)) {
+
+			$revisionHashFile = '.git/' . substr(file_get_contents($headFile), 5, -1);
+			$branchName = explode('/', $revisionHashFile)[3];
+			if(file_exists($revisionHashFile)) {
+				return 'git.' . $branchName . '.' . substr(file_get_contents($revisionHashFile), 0, 7);
+			}
+		}
+
+		return Configuration::$VERSION;
+
+	}
+
 }

+ 4 - 1
lib/Exceptions.php

@@ -64,7 +64,10 @@ function buildBridgeException($e, $bridge){
 	$body = 'Error message: `'
 	. $e->getMessage()
 	. "`\nQuery string: `"
-	. $_SERVER['QUERY_STRING'] . '`';
+	. $_SERVER['QUERY_STRING']
+	. "`\nVersion: `"
+	. Configuration::getVersion()
+	. '`';
 
 	$link = buildGitHubIssueQuery($title, $body, 'bug report', $bridge->getMaintainer());
 

+ 5 - 0
static/style.css

@@ -143,6 +143,11 @@ section.footer:hover {
 
 }
 
+section.footer .version {
+	
+	font-size: 80%;
+	
+}
 
 section > h2 {