aboutsummaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils/metadata.py
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2017-01-13 15:12:44 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-19 22:47:22 +0000
commitc74af56d4b8555a4430de1be21581a93d0876b39 (patch)
tree8018279fb7d3971fb3de4c10f457b075bc7a2373 /meta/lib/oeqa/utils/metadata.py
parent47aac40869234b9f1d15a3b1c05a74b541fafe40 (diff)
downloadopenembedded-core-contrib-c74af56d4b8555a4430de1be21581a93d0876b39.tar.gz
oeqa.utils.metadata: add bitbake revision information
[YOCTO #10590] (From OE-Core rev: 71ca7dab08fc500b231054249aacc90ae4aa85da) Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils/metadata.py')
-rw-r--r--meta/lib/oeqa/utils/metadata.py32
1 files changed, 19 insertions, 13 deletions
diff --git a/meta/lib/oeqa/utils/metadata.py b/meta/lib/oeqa/utils/metadata.py
index 6331c21f6d..a3c1b2b46c 100644
--- a/meta/lib/oeqa/utils/metadata.py
+++ b/meta/lib/oeqa/utils/metadata.py
@@ -51,6 +51,7 @@ def metadata_from_bb():
info_dict['host_distro'][key] = os_release[key]
info_dict['layers'] = get_layers(data_dict['BBLAYERS'])
+ info_dict['bitbake'] = git_rev_info(os.path.dirname(bb.__file__))
return info_dict
def metadata_from_data_store(d):
@@ -62,24 +63,29 @@ def metadata_from_data_store(d):
# be useful when running within bitbake.
pass
-def get_layers(layers):
- """Returns layer information in dict format"""
+def git_rev_info(path):
+ """Get git revision information as a dict"""
from git import Repo, InvalidGitRepositoryError, NoSuchPathError
+ info = OrderedDict()
+ try:
+ repo = Repo(path, search_parent_directories=True)
+ except (InvalidGitRepositoryError, NoSuchPathError):
+ return info
+ info['commit'] = repo.head.commit.hexsha
+ info['commit_count'] = repo.head.commit.count()
+ try:
+ info['branch'] = repo.active_branch.name
+ except TypeError:
+ info['branch'] = '(nobranch)'
+ return info
+
+def get_layers(layers):
+ """Returns layer information in dict format"""
layer_dict = OrderedDict()
for layer in layers.split():
layer_name = os.path.basename(layer)
- layer_dict[layer_name] = OrderedDict()
- try:
- repo = Repo(layer, search_parent_directories=True)
- except (InvalidGitRepositoryError, NoSuchPathError):
- continue
- layer_dict[layer_name]['commit'] = repo.head.commit.hexsha
- layer_dict[layer_name]['commit_count'] = repo.head.commit.count()
- try:
- layer_dict[layer_name]['branch'] = repo.active_branch.name
- except TypeError:
- layer_dict[layer_name]['branch'] = '(nobranch)'
+ layer_dict[layer_name] = git_rev_info(layer)
return layer_dict
def write_metadata_file(file_path, metadata):