From c7c3113dec6041e5739d8d021c76bcb6641a26e6 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 15 Nov 2012 22:11:38 +0000 Subject: [PATCH] Fix `salt.version.__version__` with git revision. * Make sure were issuing `git describe` on salt's source directory, not any other directory which might get us the wrong version string. --- salt/version.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/salt/version.py b/salt/version.py index 06ba8e95a5..8d11fc3120 100644 --- a/salt/version.py +++ b/salt/version.py @@ -6,13 +6,19 @@ __version__ = '.'.join(map(str, __version_info__)) # If we can get a version from Git use that instead, otherwise carry on try: + import os import subprocess from salt.utils import which git = which('git') if git: - p = subprocess.Popen([git, 'describe'], - stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) + p = subprocess.Popen( + [git, 'describe'], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + close_fds=True, + cwd=os.path.abspath(os.path.dirname(__file__)) + ) out, err = p.communicate() if out: __version__ = '{0}'.format(out.strip().lstrip('v'))