From: Alexis Lothoré <alexis.loth...@bootlin.com> e9cff55e73cc has switched tag listing from bare "git tag" to "git ls-remote" to make sure not to miss remote tags which are not fetched locally. This mechanism first checks for configured remote repository, next for possibly passed url, and then fails if none worked.
However there are still cases where no remote repository is configured and no url is provided (for instance: buildperf tests use an empty git directory to store tests). Fix those cases by putting back the old behavior (local tags check) as last resort, with at least a warning for future diagnostics if we still encounter tagging issues Fixes: e9cff55e73cc ("oeqa/utils/gitarchive: fix tag computation when creating archive") Signed-off-by: Alexis Lothoré <alexis.loth...@bootlin.com> --- .../oeqa/selftest/cases/gitarchivetests.py | 14 ++++++----- meta/lib/oeqa/utils/gitarchive.py | 25 ++++++++++++------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/gitarchivetests.py b/meta/lib/oeqa/selftest/cases/gitarchivetests.py index e19fd4f28088..71382089c124 100644 --- a/meta/lib/oeqa/selftest/cases/gitarchivetests.py +++ b/meta/lib/oeqa/selftest/cases/gitarchivetests.py @@ -115,13 +115,15 @@ class GitArchiveTests(OESelftestTestCase): self.assertIn("yocto-4.2", tags) delete_fake_repository(path) - def test_get_tags_without_valid_remote_neither_url(self): - url = 'git://git.yoctoproject.org/poky' - path, git_obj = create_fake_repository(False, None, False) + def test_get_tags_with_only_local_tag(self): + fake_tags_list=["main/10-g0f7d5df/0", "main/10-g0f7d5df/1", "foo/20-g2468f5d/0"] + path, git_obj = create_fake_repository(True, fake_tags_list, False) - """Test for some well established tags (released tags)""" - with self.assertRaises(GitError): - tags = ga.get_tags(git_obj, self.log, pattern="yocto-*") + """No remote is configured and no url is passed: get_tags must fall + back to local tags + """ + tags = ga.get_tags(git_obj, self.log) + self.assertCountEqual(tags, fake_tags_list) delete_fake_repository(path) def test_get_tags_without_valid_remote_and_wrong_url(self): diff --git a/meta/lib/oeqa/utils/gitarchive.py b/meta/lib/oeqa/utils/gitarchive.py index c15a44ce9e4c..ac36ecb3a9ca 100644 --- a/meta/lib/oeqa/utils/gitarchive.py +++ b/meta/lib/oeqa/utils/gitarchive.py @@ -116,18 +116,25 @@ def get_tags(repo, log, pattern=None, url=None): cmd.append(pattern) try: tags_refs = repo.run_cmd(cmd) + tags = ["".join(d.split()[1].split('/', 2)[2:]) for d in tags_refs.splitlines()] except GitError as e: # If it fails, retry with repository url if one is provided - if not url: - raise(e) - log.info("No remote repository configured, use provided url") - cmd = base_cmd.copy() - cmd.append(url) - if pattern: - cmd.append(pattern) - tags_refs = repo.run_cmd(cmd) + if url: + log.info("No remote repository configured, use provided url") + cmd = base_cmd.copy() + cmd.append(url) + if pattern: + cmd.append(pattern) + tags_refs = repo.run_cmd(cmd) + tags = ["".join(d.split()[1].split('/', 2)[2:]) for d in tags_refs.splitlines()] + else: + log.warning("Read local tags only, some remote tags may be missed") + cmd = ["tag"] + if pattern: + cmd += ["-l", pattern] + tags = repo.run_cmd(cmd).splitlines() - return ["".join(d.split()[1].split('/', 2)[2:]) for d in tags_refs.splitlines()] + return tags def expand_tag_strings(repo, name_pattern, msg_subj_pattern, msg_body_pattern, url, log, keywords): -- 2.41.0
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#186568): https://lists.openembedded.org/g/openembedded-core/message/186568 Mute This Topic: https://lists.openembedded.org/mt/100911949/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-