From 292cf8f32d5c50aeed1641ffd95aafc4341350e7 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Tue, 22 Jul 2014 16:26:39 +0200 Subject: [PATCH] Fix Mopidy version when run from another Git repo (related to #706) --- docs/changelog.rst | 6 ++++++ mopidy/utils/versioning.py | 13 +++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index c73c5a44..c461db63 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -13,6 +13,12 @@ v0.19.1 (UNRELEASED) Mopidy continue to work on Debian/Raspbian stable, where Tornado 2.3 is the newest version available. +**Development** + +- ``mopidy --version`` and :meth:`mopidy.core.Core.get_version` now returns the + correct version when Mopidy is run from a Git repo other than Mopidy's own. + (Related to :issue:`706`) + v0.19.0 (2014-07-21) ==================== diff --git a/mopidy/utils/versioning.py b/mopidy/utils/versioning.py index e8856473..94578121 100644 --- a/mopidy/utils/versioning.py +++ b/mopidy/utils/versioning.py @@ -1,19 +1,24 @@ from __future__ import unicode_literals -from subprocess import PIPE, Popen +import os +import subprocess -from mopidy import __version__ +import mopidy def get_version(): try: return get_git_version() except EnvironmentError: - return __version__ + return mopidy.__version__ def get_git_version(): - process = Popen(['git', 'describe'], stdout=PIPE, stderr=PIPE) + project_dir = os.path.abspath( + os.path.join(os.path.dirname(mopidy.__file__), '..')) + process = subprocess.Popen( + ['git', 'describe'], + stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=project_dir) if process.wait() != 0: raise EnvironmentError('Execution of "git describe" failed') version = process.stdout.read().strip()