diff options
-rw-r--r-- | meta/lib/oeqa/selftest/cases/gitarchivetests.py | 14 | ||||
-rw-r--r-- | 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 e19fd4f280..71382089c1 100644 --- a/meta/lib/oeqa/selftest/cases/gitarchivetests.py +++ b/meta/lib/oeqa/selftest/cases/gitarchivetests.py | |||
@@ -115,13 +115,15 @@ class GitArchiveTests(OESelftestTestCase): | |||
115 | self.assertIn("yocto-4.2", tags) | 115 | self.assertIn("yocto-4.2", tags) |
116 | delete_fake_repository(path) | 116 | delete_fake_repository(path) |
117 | 117 | ||
118 | def test_get_tags_without_valid_remote_neither_url(self): | 118 | def test_get_tags_with_only_local_tag(self): |
119 | url = 'git://git.yoctoproject.org/poky' | 119 | fake_tags_list=["main/10-g0f7d5df/0", "main/10-g0f7d5df/1", "foo/20-g2468f5d/0"] |
120 | path, git_obj = create_fake_repository(False, None, False) | 120 | path, git_obj = create_fake_repository(True, fake_tags_list, False) |
121 | 121 | ||
122 | """Test for some well established tags (released tags)""" | 122 | """No remote is configured and no url is passed: get_tags must fall |
123 | with self.assertRaises(GitError): | 123 | back to local tags |
124 | tags = ga.get_tags(git_obj, self.log, pattern="yocto-*") | 124 | """ |
125 | tags = ga.get_tags(git_obj, self.log) | ||
126 | self.assertCountEqual(tags, fake_tags_list) | ||
125 | delete_fake_repository(path) | 127 | delete_fake_repository(path) |
126 | 128 | ||
127 | def test_get_tags_without_valid_remote_and_wrong_url(self): | 129 | 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 c15a44ce9e..ac36ecb3a9 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): | |||
116 | cmd.append(pattern) | 116 | cmd.append(pattern) |
117 | try: | 117 | try: |
118 | tags_refs = repo.run_cmd(cmd) | 118 | tags_refs = repo.run_cmd(cmd) |
119 | tags = ["".join(d.split()[1].split('/', 2)[2:]) for d in tags_refs.splitlines()] | ||
119 | except GitError as e: | 120 | except GitError as e: |
120 | # If it fails, retry with repository url if one is provided | 121 | # If it fails, retry with repository url if one is provided |
121 | if not url: | 122 | if url: |
122 | raise(e) | 123 | log.info("No remote repository configured, use provided url") |
123 | log.info("No remote repository configured, use provided url") | 124 | cmd = base_cmd.copy() |
124 | cmd = base_cmd.copy() | 125 | cmd.append(url) |
125 | cmd.append(url) | 126 | if pattern: |
126 | if pattern: | 127 | cmd.append(pattern) |
127 | cmd.append(pattern) | 128 | tags_refs = repo.run_cmd(cmd) |
128 | tags_refs = repo.run_cmd(cmd) | 129 | tags = ["".join(d.split()[1].split('/', 2)[2:]) for d in tags_refs.splitlines()] |
130 | else: | ||
131 | log.warning("Read local tags only, some remote tags may be missed") | ||
132 | cmd = ["tag"] | ||
133 | if pattern: | ||
134 | cmd += ["-l", pattern] | ||
135 | tags = repo.run_cmd(cmd).splitlines() | ||
129 | 136 | ||
130 | return ["".join(d.split()[1].split('/', 2)[2:]) for d in tags_refs.splitlines()] | 137 | return tags |
131 | 138 | ||
132 | def expand_tag_strings(repo, name_pattern, msg_subj_pattern, msg_body_pattern, | 139 | def expand_tag_strings(repo, name_pattern, msg_subj_pattern, msg_body_pattern, |
133 | url, log, keywords): | 140 | url, log, keywords): |