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-12-16 14:31:27 +0000
commit1f1367a59d9920b9e7a902200e9145cfcd9bd20a (patch)
treed99997bc3ad69c2b1d211fb7c412104d6f1ff358 /meta/lib
parent152a347f8d2ae52be060c4793a026bb2a330b5a8 (diff)
downloadpoky-1f1367a59d9920b9e7a902200e9145cfcd9bd20a.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) (From OE-Core rev: 32c9169b76e13e53b6a9ab4a59932cea7863d992) 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):