diff options
author | Simon Warta <[email protected]> | 2017-04-03 19:17:10 +0200 |
---|---|---|
committer | Simon Warta <[email protected]> | 2017-04-03 19:17:10 +0200 |
commit | d40c3e0a0712ce17ab9a54f62d4aac7476855f63 (patch) | |
tree | 19e9fe24dac650c87220e68376ee156edf082af7 | |
parent | 32d17f89c614a759b6747507daaeecb4ca2dea7b (diff) |
Move _local_repo_vc_revision to Version
-rwxr-xr-x | configure.py | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/configure.py b/configure.py index 176d43acd..528f121ab 100755 --- a/configure.py +++ b/configure.py @@ -52,32 +52,6 @@ def chunks(l, n): yield l[i:i+n] -def get_vc_revision(): - vc_command = ['git', 'rev-parse', 'HEAD'] - cmdname = vc_command[0] - - try: - vc = subprocess.Popen( - vc_command, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - universal_newlines=True) - (stdout, stderr) = vc.communicate() - - if vc.returncode != 0: - logging.debug('Error getting rev from %s - %d (%s)' - % (cmdname, vc.returncode, stderr)) - return None - - rev = str(stdout).strip() - logging.debug('%s reported revision %s' % (cmdname, rev)) - - return '%s:%s' % (cmdname, rev) - except OSError as e: - logging.debug('Error getting rev from %s - %s' % (cmdname, e.strerror)) - return None - - class Version(object): """ Version information are all static members @@ -97,15 +71,41 @@ class Version(object): @staticmethod def vc_rev(): - # Lazy load to ensure get_vc_revision() does not run before logger is set up + # Lazy load to ensure _local_repo_vc_revision() does not run before logger is set up if Version._vc_rev is None: Version._vc_rev = botan_version.release_vc_rev if Version._vc_rev is None: - Version._vc_rev = get_vc_revision() + Version._vc_rev = Version._local_repo_vc_revision() if Version._vc_rev is None: Version._vc_rev = 'unknown' return Version._vc_rev + @staticmethod + def _local_repo_vc_revision(): + vc_command = ['git', 'rev-parse', 'HEAD'] + cmdname = vc_command[0] + + try: + vc = subprocess.Popen( + vc_command, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + universal_newlines=True) + (stdout, stderr) = vc.communicate() + + if vc.returncode != 0: + logging.debug('Error getting rev from %s - %d (%s)' + % (cmdname, vc.returncode, stderr)) + return None + + rev = str(stdout).strip() + logging.debug('%s reported revision %s' % (cmdname, rev)) + + return '%s:%s' % (cmdname, rev) + except OSError as e: + logging.debug('Error getting rev from %s - %s' % (cmdname, e.strerror)) + return None + class BuildPaths(object): # pylint: disable=too-many-instance-attributes """ |