summaryrefslogtreecommitdiff
path: root/common/doc
diff options
context:
space:
mode:
authorJean-Philippe SAVE2013-02-14 14:59:10 +0100
committerJean-Philippe SAVE2013-02-15 18:58:18 +0100
commit51187c3124c7c97e3305e61266761eb917e0c0db (patch)
treed93d6e6c3811f833e9fb7683510545192c65dccf /common/doc
parent8672c16cefb9afd6c593774b03b27c40580ea37e (diff)
{cleo, common/doc/template/mstar}: find version for bundle mode, closes #3750
Diffstat (limited to 'common/doc')
-rw-r--r--common/doc/template/mstar/vcs_version_directive.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/common/doc/template/mstar/vcs_version_directive.py b/common/doc/template/mstar/vcs_version_directive.py
index 3fcc00891d..489665a7df 100644
--- a/common/doc/template/mstar/vcs_version_directive.py
+++ b/common/doc/template/mstar/vcs_version_directive.py
@@ -1,4 +1,5 @@
"""Define and register a vcs-version directive"""
+import os.path
from docutils import nodes
from docutils.parsers.rst import directives, Directive, states
@@ -13,13 +14,26 @@ class VcsVersion(Directive):
'a substitution definition.' % self.name)
return [nodes.Text(self.get_version())]
+ def get_base(self):
+ path = os.path.abspath(os.getcwd()),
+ while (not os.path.exists(os.path.join(path[0], 'common/doc/template'))
+ and path[0] != '/'):
+ path = os.path.split(path[0])
+ return path[0]
+
def get_version(self):
import subprocess
- p = subprocess.Popen(['git', 'describe', '--always'],
- stdout=subprocess.PIPE)
- output = p.communicate()[0]
- if p.returncode != 0:
- raise self.error('%s: can not determine version' % self.name)
+ version_path = os.path.join(self.get_base(), '.version')
+ if os.path.exists(version_path):
+ fd_version = open(version_path)
+ output = fd_version.readline()
+ fd_version.close()
+ else:
+ p = subprocess.Popen(['git', 'describe', '--always'],
+ stdout=subprocess.PIPE)
+ output = p.communicate()[0]
+ if p.returncode != 0:
+ raise self.error('%s: can not determine version' % self.name)
return output
directives.register_directive('vcs-version', VcsVersion)