From: John Ripple <john.ripple@keysight.com>
To: openembedded-core@lists.openembedded.org
Cc: John Ripple <john.ripple@keysight.com>
Subject: [OE-core] [meta][PATCH 3/3] oeqa/utils/metadata: Handle empty git repos in git_rev_info
Date: Tue, 7 Jul 2026 15:14:56 -0600 [thread overview]
Message-ID: <20260707211507.2585072-3-john.ripple@keysight.com> (raw)
In-Reply-To: <cover.1783457902.git.john.ripple@keysight.com>
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 <john.ripple@keysight.com>
---
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
next prev parent reply other threads:[~2026-07-07 21:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 21:14 [OE Core] [meta][PATCH 0/3] Create selftest suite for go-vendor.bbclass John Ripple
2026-07-07 21:14 ` [OE-core] [meta][PATCH 1/3] go-vendor.bbclass: Fix test file exclusion and license propagation John Ripple
2026-07-07 21:14 ` [OE-core] [meta][PATCH 2/3] oeqa/selftest: Add go-vendor.bbclass selftest suite John Ripple
2026-07-09 10:08 ` Alexander Kanavin
2026-07-07 21:14 ` John Ripple [this message]
2026-07-09 10:10 ` [OE-core] [meta][PATCH 3/3] oeqa/utils/metadata: Handle empty git repos in git_rev_info Alexander Kanavin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260707211507.2585072-3-john.ripple@keysight.com \
--to=john.ripple@keysight.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox