summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2018-10-29 13:46:52 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-10-29 17:26:47 +0000
commit44ee41052cfe2c7df8caca2d06d339ce46af9945 (patch)
treecbb0d43822fbff07c467f95231ef0e5e05f707da /meta/lib
parent4b9ef43274d2af757c162a4536530281bdaba493 (diff)
downloadpoky-44ee41052cfe2c7df8caca2d06d339ce46af9945.tar.gz
oeqa/utils/metadata: Allow to function without the git module
The python git module may or may not be enabled, allow this code to function without it, falling back to the same method as metadata_scm.bbclass uses. This will be cleaned up in the next round of feature development. (From OE-Core rev: 6350586ba9f4a4107a2d457590824cd4d662d5b9) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/utils/metadata.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/meta/lib/oeqa/utils/metadata.py b/meta/lib/oeqa/utils/metadata.py
index 65bbdc61f4..b7def77224 100644
--- a/meta/lib/oeqa/utils/metadata.py
+++ b/meta/lib/oeqa/utils/metadata.py
@@ -58,9 +58,22 @@ def metadata_from_data_store(d):
58 58
59def git_rev_info(path): 59def git_rev_info(path):
60 """Get git revision information as a dict""" 60 """Get git revision information as a dict"""
61 from git import Repo, InvalidGitRepositoryError, NoSuchPathError
62
63 info = OrderedDict() 61 info = OrderedDict()
62
63 try:
64 from git import Repo, InvalidGitRepositoryError, NoSuchPathError
65 except ImportError:
66 import subprocess
67 try:
68 info['branch'] = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"], cwd=path).decode('utf-8').strip()
69 except subprocess.CalledProcessError:
70 pass
71 try:
72 info['commit'] = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=path).decode('utf-8').strip()
73 except subprocess.CalledProcessError:
74 pass
75 return info
76
64 try: 77 try:
65 repo = Repo(path, search_parent_directories=True) 78 repo = Repo(path, search_parent_directories=True)
66 except (InvalidGitRepositoryError, NoSuchPathError): 79 except (InvalidGitRepositoryError, NoSuchPathError):