git_rev_info() calls repo.head.commit without guarding against ValueError, which gitpython raises when HEAD points to an unborn branch (e.g. a freshly-initialised layer directory with no commits). Wrap the commit-info block in try/except so metadata collection continues rather than crashing with a non-zero exit code.
Signed-off-by: John Ripple <[email protected]> --- meta/lib/oeqa/utils/metadata.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/meta/lib/oeqa/utils/metadata.py b/meta/lib/oeqa/utils/metadata.py index b320df67e0..c8df17392d 100644 --- a/meta/lib/oeqa/utils/metadata.py +++ b/meta/lib/oeqa/utils/metadata.py @@ -85,12 +85,15 @@ def git_rev_info(path): 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() - info['commit_time'] = repo.head.commit.committed_date + try: + info['commit'] = repo.head.commit.hexsha + info['commit_count'] = repo.head.commit.count() + info['commit_time'] = repo.head.commit.committed_date + except (ValueError, TypeError): + pass try: info['branch'] = repo.active_branch.name - except TypeError: + except (TypeError, ValueError): info['branch'] = '(nobranch)' return info
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#240410): https://lists.openembedded.org/g/openembedded-core/message/240410 Mute This Topic: https://lists.openembedded.org/mt/120164248/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
