diff mbox series

[4/9] fetch2/git: keep the gitpkgv commit count numeric

Message ID 20260625070750.2757558-5-anders.heimer@est.tech
State New
Headers show
Series Follow-up fixes for command argument conversions | expand

Commit Message

Anders Heimer June 25, 2026, 7:07 a.m. UTC
The cold-cache path used to keep the raw splitlines() list in
commits while only using len(commits) when writing the cache file.

That same commits value is formatted into the returned version string
below, so cold cache could return a Python list representation while
warm cache returned the numeric count. Store the numeric count in
commits before both writing the cache and building the return value.

Signed-off-by: Anders Heimer <anders.heimer@est.tech>
---
 lib/bb/fetch2/git.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index 00983b744..0bb2ea39a 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -1031,9 +1031,9 @@  class Git(FetchMethod):
             commits = None
         else:
             if not os.path.exists(rev_file) or not os.path.getsize(rev_file):
-                commits = bb.fetch2.runfetchcmd(['git', 'rev-list', rev, '--'], d).splitlines()
+                commits = len(bb.fetch2.runfetchcmd(['git', 'rev-list', rev, '--'], d).splitlines())
                 if commits:
-                    open(rev_file, "w").write("%d\n" % len(commits))
+                    open(rev_file, "w").write("%d\n" % commits)
             else:
                 commits = open(rev_file, "r").readline(128).strip()
         if commits: