validate: Determine development mode using git hash value

Development mode has been determined by whether the launcher is in git
repo
or not. This could be wrong when the launcher is installed to
subdirectory of other project's git repo, such as jhbuild. It is normal
to install compiled output to subdirectory of your jhbuild.

Changed logic gets the first commit hash of current git repo and
compares it with gst-devtools' the first commit hash.

https://bugzilla.gnome.org/show_bug.cgi?id=744781
This commit is contained in:
Young Han Lee 2015-02-19 20:53:16 +09:00 committed by Thibault Saunier
parent c5393f79f3
commit 2d6c667c9a

View file

@ -18,21 +18,31 @@
# Boston, MA 02110-1301, USA. # Boston, MA 02110-1301, USA.
import os import os
import subprocess
import sys import sys
LIBDIR = '@LIBDIR@' LIBDIR = '@LIBDIR@'
GIT_FIRST_HASH = 'da962d096af9460502843e41b7d25fdece7ff1c2'
def _get_git_first_hash(path):
try:
return subprocess.check_output(['git', '-C', path, 'rev-list', '--max-parents=0', 'HEAD']).rstrip('\n')
except subprocess.CalledProcessError:
return ''
def _in_devel(): def _in_devel():
root_dir = os.path.abspath(os.path.dirname(os.path.join(os.path.dirname(os.path.abspath(__file__)), root_dir = os.path.abspath(os.path.dirname(os.path.join(os.path.dirname(os.path.abspath(__file__)),
"..", "..", ".."))) "..", "..", "..")))
return os.path.exists(os.path.join(root_dir, '.git')) return _get_git_first_hash(root_dir) == GIT_FIRST_HASH
def _add_gst_launcher_path(): def _add_gst_launcher_path():
if not _in_devel(): if not _in_devel():
root = os.path.join(LIBDIR, 'gst-validate-launcher', 'python') root = os.path.join(LIBDIR, 'gst-validate-launcher', 'python')
else: else:
print "Running with development path"
dir_ = os.path.dirname(os.path.abspath(__file__)) dir_ = os.path.dirname(os.path.abspath(__file__))
root = os.path.split(dir_)[0] root = os.path.split(dir_)[0]