diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2017-01-13 15:12:40 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-01-19 22:47:22 +0000 |
commit | 927e759bb2d229ff023b58cce498ed3ae19af46a (patch) | |
tree | e681a6ea0a9a354a7f4279cbf5037da9b1e49d21 | |
parent | 4e67232f345a8756f20c6dc41a52e5c80533598c (diff) | |
download | poky-927e759bb2d229ff023b58cce498ed3ae19af46a.tar.gz |
oeqa.utils.metadata: fix retrieval of git branch and revision
Always return a valid branch name, or, '(nobranch)' if the current HEAD
is detached. Also, always return the hash of the commit object that HEAD
is pointing to. Previous code returned an incorrect branch name (or
crashed) e.g. in the case of detached HEAD.
[YOCTO #10590]
(From OE-Core rev: 02d3ba17a8090bd088beb973980651d664f713bb)
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>
-rw-r--r-- | meta/lib/oeqa/utils/metadata.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/meta/lib/oeqa/utils/metadata.py b/meta/lib/oeqa/utils/metadata.py index a389c6a28e..b732d372df 100644 --- a/meta/lib/oeqa/utils/metadata.py +++ b/meta/lib/oeqa/utils/metadata.py | |||
@@ -72,11 +72,13 @@ def get_layers(layers): | |||
72 | layer_dict[layer_name] = OrderedDict() | 72 | layer_dict[layer_name] = OrderedDict() |
73 | try: | 73 | try: |
74 | repo = Repo(layer, search_parent_directories=True) | 74 | repo = Repo(layer, search_parent_directories=True) |
75 | revision, branch = repo.head.object.name_rev.split() | ||
76 | except (InvalidGitRepositoryError, NoSuchPathError): | 75 | except (InvalidGitRepositoryError, NoSuchPathError): |
77 | continue | 76 | continue |
78 | layer_dict[layer_name]['branch'] = branch | 77 | layer_dict[layer_name]['revision'] = repo.head.commit.hexsha |
79 | layer_dict[layer_name]['revision'] = revision | 78 | try: |
79 | layer_dict[layer_name]['branch'] = repo.active_branch.name | ||
80 | except TypeError: | ||
81 | layer_dict[layer_name]['branch'] = '(nobranch)' | ||
80 | return layer_dict | 82 | return layer_dict |
81 | 83 | ||
82 | def write_metadata_file(file_path, metadata): | 84 | def write_metadata_file(file_path, metadata): |