summaryrefslogtreecommitdiffstats
path: root/meta/lib
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
parent47aac40869234b9f1d15a3b1c05a74b541fafe40 (diff)
downloadpoky-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')
-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():
51 info_dict['host_distro'][key] = os_release[key] 51 info_dict['host_distro'][key] = os_release[key]
52 52
53 info_dict['layers'] = get_layers(data_dict['BBLAYERS']) 53 info_dict['layers'] = get_layers(data_dict['BBLAYERS'])
54 info_dict['bitbake'] = git_rev_info(os.path.dirname(bb.__file__))
54 return info_dict 55 return info_dict
55 56
56def metadata_from_data_store(d): 57def metadata_from_data_store(d):
@@ -62,24 +63,29 @@ def metadata_from_data_store(d):
62 # be useful when running within bitbake. 63 # be useful when running within bitbake.
63 pass 64 pass
64 65
65def get_layers(layers): 66def git_rev_info(path):
66 """Returns layer information in dict format""" 67 """Get git revision information as a dict"""
67 from git import Repo, InvalidGitRepositoryError, NoSuchPathError 68 from git import Repo, InvalidGitRepositoryError, NoSuchPathError
68 69
70 info = OrderedDict()
71 try:
72 repo = Repo(path, search_parent_directories=True)
73 except (InvalidGitRepositoryError, NoSuchPathError):
74 return info
75 info['commit'] = repo.head.commit.hexsha
76 info['commit_count'] = repo.head.commit.count()
77 try:
78 info['branch'] = repo.active_branch.name
79 except TypeError:
80 info['branch'] = '(nobranch)'
81 return info
82
83def get_layers(layers):
84 """Returns layer information in dict format"""
69 layer_dict = OrderedDict() 85 layer_dict = OrderedDict()
70 for layer in layers.split(): 86 for layer in layers.split():
71 layer_name = os.path.basename(layer) 87 layer_name = os.path.basename(layer)
72 layer_dict[layer_name] = OrderedDict() 88 layer_dict[layer_name] = git_rev_info(layer)
73 try:
74 repo = Repo(layer, search_parent_directories=True)
75 except (InvalidGitRepositoryError, NoSuchPathError):
76 continue
77 layer_dict[layer_name]['commit'] = repo.head.commit.hexsha
78 layer_dict[layer_name]['commit_count'] = repo.head.commit.count()
79 try:
80 layer_dict[layer_name]['branch'] = repo.active_branch.name
81 except TypeError:
82 layer_dict[layer_name]['branch'] = '(nobranch)'
83 return layer_dict 89 return layer_dict
84 90
85def write_metadata_file(file_path, metadata): 91def write_metadata_file(file_path, metadata):