Browse Source

special version reporting for git

Andrew Dolgov 11 years ago
parent
commit
6316898f8d
1 changed files with 16 additions and 1 deletions
  1. 16 1
      include/version.php

+ 16 - 1
include/version.php

@@ -1,3 +1,18 @@
 <?php
-	define('VERSION', "1.7.8");
+	define('VERSION_STATIC', '1.7.8');
+
+	function get_version() {
+		$root_dir = dirname(dirname(__FILE__));
+
+		if (is_dir("$root_dir/.git") && file_exists("$root_dir/.git/ORIG_HEAD")) {
+
+			$suffix = date("Ymd", filemtime("$root_dir/.git/ORIG_HEAD"));
+
+			return VERSION_STATIC . ".$suffix";
+		} else {
+			return VERSION_STATIC;
+		}
+	}
+
+	define('VERSION', get_version());
 ?>