From: raslene.ziadi@gmail.com
To: buildroot@buildroot.org
Cc: Sen Hastings <sen@hastings.org>,
Raslen Ziadi <raslen.ziadi@enim.u-monastir.tn>
Subject: [Buildroot] [PATCH 1/1] support/scripts/pkg-stats: handle missing git repository
Date: Wed, 21 Oct 2026 14:46:55 +0100 [thread overview]
Message-ID: <20261021134656.30706-1-raslene.ziadi@gmail.com> (raw)
From: Raslen Ziadi <raslen.ziadi@enim.u-monastir.tn>
pkg-stats can be run outside a Git repository. In this case,
retrieving the current commit fails and aborts the script.
Handle this failure and omit the commit information from the HTML
and JSON reports when the Git commit is unavailable.
Signed-off-by: Raslen Ziadi <raslen.ziadi@enim.u-monastir.tn>
---
support/scripts/pkg-stats | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index eb6d1836c3..52a4293948 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -1260,7 +1260,10 @@ def dump_html_stats(f, stats):
def dump_html_gen_info(f, date, commit):
# Updated on Mon Feb 19 08:12:08 CET 2018, Git commit aa77030b8f5e41f1c53eb1c1ad664b8c814ba032
- f.write("<p><i>Updated on %s, git commit %s</i></p>\n" % (str(date), commit))
+ if commit:
+ f.write("<p><i>Updated on %s, git commit %s</i></p>\n" % (str(date), commit))
+ else:
+ f.write("<p><i>Updated on %s</i></p>\n" % str(date))
def dump_html(packages, stats, date, commit, output):
@@ -1300,9 +1303,10 @@ def dump_json(packages, defconfigs, stats, date, commit, output):
final = {'packages': pkgs,
'stats': statistics,
'defconfigs': defconfigs,
- 'package_status_checks': Package.status_checks,
- 'commit': commit,
- 'date': str(date)}
+ 'package_status_checks': Package.status_checks}
+ if commit:
+ final['commit'] = commit
+ final['date'] = str(date)
with open(output, 'w') as f:
json.dump(final, f, indent=2, separators=(',', ': '))
@@ -1371,9 +1375,13 @@ def main():
else:
package_list = None
date = datetime.datetime.now(datetime.timezone.utc)
- commit = subprocess.check_output(['git', '-C', brpath,
- 'rev-parse',
- 'HEAD']).splitlines()[0].decode()
+ try:
+ commit = subprocess.check_output(
+ ['git', '-C', brpath, 'rev-parse', 'HEAD'],
+ stderr=subprocess.DEVNULL
+ ).splitlines()[0].decode()
+ except subprocess.CalledProcessError:
+ commit = None
print("Build package list ...")
all_trees = get_trees()
packages = get_pkglist(all_trees, args.npackages, package_list)
--
2.43.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next reply other threads:[~2026-10-21 13:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 13:46 raslene.ziadi [this message]
2026-10-21 14:59 ` [Buildroot] [PATCH 1/1] support/scripts/pkg-stats: handle missing git repository Peter Seiderer via buildroot
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=20261021134656.30706-1-raslene.ziadi@gmail.com \
--to=raslene.ziadi@gmail.com \
--cc=buildroot@buildroot.org \
--cc=raslen.ziadi@enim.u-monastir.tn \
--cc=sen@hastings.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.