diff mbox series

[v2,3/3] bitbake-setup: correctly determine latest revision in status/update when it is fixed to a commit id

Message ID 20260309141238.1785102-3-alex.kanavin@gmail.com
State New
Headers show
Series [v2,1/3] bitbake-setup: ensure that config_id is always an absolute path | expand

Commit Message

Alexander Kanavin March 9, 2026, 2:12 p.m. UTC
From: Alexander Kanavin <alex@linutronix.de>

The code was relying on git fetcher's latest_revision() method,
which works properly if the revision in the json config template
is set to a branch or a tag, but does not work if it is set to
a fixed revision (the method will return the latest revision on the
respective branch, and bitbake-setup will incorrectly determine
that the layer needs to be updated to that revision).

Add a guard to check if the revision is a fixed commit id, and do a
direct revision comparison if so, skipping the fetcher query.

[YOCTO #16190]

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 bin/bitbake-setup | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/bin/bitbake-setup b/bin/bitbake-setup
index 19a6b5373..ca4461b1e 100755
--- a/bin/bitbake-setup
+++ b/bin/bitbake-setup
@@ -742,11 +742,18 @@  def get_diff(file1, file2):
 
 def are_layers_changed(layers, layerdir, d):
     def _is_git_remote_changed(r_remote, repodir):
+        from bb.fetch2.git import sha1_re
+
         rev = r_remote['rev']
         branch = r_remote.get('branch', None)
 
         rev_parse_result = bb.process.run('git -C {} rev-parse HEAD'.format(os.path.join(layerdir, repodir)))
         local_revision = rev_parse_result[0].strip()
+        if sha1_re.match(rev):
+            if rev != local_revision:
+                logger.info('Layer repository checked out into {} is at revision {} but should be at {}'.format(os.path.join(layerdir, repodir),local_revision, rev))
+                return True
+            return False
 
         remotes = _get_remotes(r_remote)
         changed = False