[oe-commits] [openembedded-core] 07/12: oeqa/utils/metadata: Allow to function without the git module
git at git.openembedded.org
git at git.openembedded.org
Mon Oct 29 14:07:23 UTC 2018
This is an automated email from the git hooks/post-receive script.
rpurdie pushed a commit to branch master-next
in repository openembedded-core.
commit db804e37cc3d1aacabff73a3d5beb97ee4c38e3e
Author: Richard Purdie <richard.purdie at linuxfoundation.org>
AuthorDate: Mon Oct 29 13:46:52 2018 +0000
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.
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
meta/lib/oeqa/utils/metadata.py | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/meta/lib/oeqa/utils/metadata.py b/meta/lib/oeqa/utils/metadata.py
index 65bbdc6..b7def77 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):
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list