diff options
| -rw-r--r-- | meta/lib/oeqa/utils/metadata.py | 32 |
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 | ||
| 56 | def metadata_from_data_store(d): | 57 | def 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 | ||
| 65 | def get_layers(layers): | 66 | def 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 | |||
| 83 | def 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 | ||
| 85 | def write_metadata_file(file_path, metadata): | 91 | def write_metadata_file(file_path, metadata): |
