From b7c0b4049133868df071109820ed2d989c5f1c62 Mon Sep 17 00:00:00 2001 From: Thomas Keller Date: Sun, 20 Mar 2011 00:42:56 +0100 Subject: [PATCH] Add basic source version tracking. Indefero's version is now noted in src/IDF/version.php; just before a release is made, the '-dev' is removed and after the release is made, the version should be increased and '-dev' should be added back to denote that the development for the next version started. The revision identifier is automatically set when an archive is created and is based on the revision that the archive creator gave to git-archive(1). If people follow development, we try to get the current deployed version with git-log(1) and if that fails as well, the revision is determined to be 'unknown'. Version and revision are then rendered as HTML meta tags in the header of each template. (All this is done by the new {appversion} tag.) --- .gitattributes | 1 + src/IDF/Middleware.php | 1 + src/IDF/Template/AppVersion.php | 61 ++++++++++++++++++++++++++ src/IDF/templates/idf/base-full.html | 1 + src/IDF/templates/idf/base-simple.html | 1 + src/IDF/templates/idf/base.html | 1 + src/IDF/templates/idf/gadmin/base.html | 1 + src/IDF/version.php | 5 +++ 8 files changed, 72 insertions(+) create mode 100644 .gitattributes create mode 100644 src/IDF/Template/AppVersion.php create mode 100644 src/IDF/version.php diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..404c823 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +src/IDF/version.php export-subst diff --git a/src/IDF/Middleware.php b/src/IDF/Middleware.php index b836e25..028f412 100644 --- a/src/IDF/Middleware.php +++ b/src/IDF/Middleware.php @@ -87,6 +87,7 @@ class IDF_Middleware 'markdown' => 'IDF_Template_Markdown', 'showuser' => 'IDF_Template_ShowUser', 'ashowuser' => 'IDF_Template_AssignShowUser', + 'appversion' => 'IDF_Template_AppVersion', )); $params['modifiers'] = array_merge($params['modifiers'], array( diff --git a/src/IDF/Template/AppVersion.php b/src/IDF/Template/AppVersion.php new file mode 100644 index 0000000..00d6f2a --- /dev/null +++ b/src/IDF/Template/AppVersion.php @@ -0,0 +1,61 @@ +'."\n"; + } + + if (array_key_exists('revision', $info)) { + if (strpos($info['revision'], '$') !== false) { + $info['revision'] = 'unknown'; + $cmd = Pluf::f('idf_exec_cmd_prefix', ''). + Pluf::f('git_path', 'git'). + ' log -1 --format=%H'; + + if (IDF_Scm::exec('IDF_Template_AppVersion::start', $cmd, $output)) { + $info['revision'] = trim(@$output[0]); + } + } + echo ''."\n"; + } + } +} + diff --git a/src/IDF/templates/idf/base-full.html b/src/IDF/templates/idf/base-full.html index d2e69fa..8e19345 100644 --- a/src/IDF/templates/idf/base-full.html +++ b/src/IDF/templates/idf/base-full.html @@ -32,6 +32,7 @@ {block extraheader}{/block} {block pagetitle}{$page_title|strip_tags}{/block}{if $project} - {$project.shortdesc}{/if} + {appversion}
diff --git a/src/IDF/templates/idf/base-simple.html b/src/IDF/templates/idf/base-simple.html index 39c1a9b..8a0a3d5 100644 --- a/src/IDF/templates/idf/base-simple.html +++ b/src/IDF/templates/idf/base-simple.html @@ -32,6 +32,7 @@ {block extraheader}{/block} {block pagetitle}{$page_title|strip_tags}{/block} + {appversion}
diff --git a/src/IDF/templates/idf/base.html b/src/IDF/templates/idf/base.html index 0d3cfb1..cfddd85 100644 --- a/src/IDF/templates/idf/base.html +++ b/src/IDF/templates/idf/base.html @@ -32,6 +32,7 @@ {block extraheader}{/block} {block pagetitle}{$page_title|strip_tags}{/block}{if $project} - {$project.shortdesc}{/if} + {appversion}
diff --git a/src/IDF/templates/idf/gadmin/base.html b/src/IDF/templates/idf/gadmin/base.html index 15e830d..4f8a745 100644 --- a/src/IDF/templates/idf/gadmin/base.html +++ b/src/IDF/templates/idf/gadmin/base.html @@ -31,6 +31,7 @@ {block extraheader}{/block} {block pagetitle}{$page_title|strip_tags}{/block} + {appversion}
diff --git a/src/IDF/version.php b/src/IDF/version.php new file mode 100644 index 0000000..cd5ca11 --- /dev/null +++ b/src/IDF/version.php @@ -0,0 +1,5 @@ + '1.1-dev', + 'revision' => '$Format:%H$', +);