aboutsummaryrefslogtreecommitdiffstats
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-06 13:58:19 +0000
commit32c9169b76e13e53b6a9ab4a59932cea7863d992 (patch)
treeeb10e3e8ab1470eb9e6f7695c8957e44445bb1e5 /meta/lib
parent9f2e39684cbbe9f87eeef6a81961e6db783439e3 (diff)
downloadopenembedded-core-contrib-32c9169b76e13e53b6a9ab4a59932cea7863d992.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):
def git_rev_info(path):
"""Get git revision information as a dict"""
- from git import Repo, InvalidGitRepositoryError, NoSuchPathError
-
info = OrderedDict()
+
+ try:
+ from git import Repo, InvalidGitRepositoryError, NoSuchPathError
+ except ImportError:
+ import subprocess
+ try:
+ info['branch'] = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"], cwd=path).decode('utf-8').strip()
+ except subprocess.CalledProcessError:
+ pass
+ try:
+ info['commit'] = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=path).decode('utf-8').strip()
+ except subprocess.CalledProcessError:
+ pass
+ return info
+
try:
repo = Repo(path, search_parent_directories=True)
except (InvalidGitRepositoryError, NoSuchPathError):