summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oeqa/selftest/cases/gitarchivetests.py13
-rw-r--r--meta/lib/oeqa/utils/gitarchive.py11
2 files changed, 16 insertions, 8 deletions
diff --git a/meta/lib/oeqa/selftest/cases/gitarchivetests.py b/meta/lib/oeqa/selftest/cases/gitarchivetests.py
index 11b88daab8..e19fd4f280 100644
--- a/meta/lib/oeqa/selftest/cases/gitarchivetests.py
+++ b/meta/lib/oeqa/selftest/cases/gitarchivetests.py
@@ -14,6 +14,7 @@ from oeqa.utils.git import GitError
14import tempfile 14import tempfile
15import shutil 15import shutil
16import scriptutils 16import scriptutils
17import logging
17from oeqa.selftest.case import OESelftestTestCase 18from oeqa.selftest.case import OESelftestTestCase
18 19
19logger = scriptutils.logger_create('resulttool') 20logger = scriptutils.logger_create('resulttool')
@@ -58,6 +59,12 @@ class GitArchiveTests(OESelftestTestCase):
58 TEST_COMMIT="0f7d5df" 59 TEST_COMMIT="0f7d5df"
59 TEST_COMMIT_COUNT="42" 60 TEST_COMMIT_COUNT="42"
60 61
62 @classmethod
63 def setUpClass(cls):
64 super().setUpClass()
65 cls.log = logging.getLogger('gitarchivetests')
66 cls.log.setLevel(logging.DEBUG)
67
61 def test_create_first_test_tag(self): 68 def test_create_first_test_tag(self):
62 path, git_obj = create_fake_repository(False) 69 path, git_obj = create_fake_repository(False)
63 keywords = {'commit': self.TEST_COMMIT, 'branch': self.TEST_BRANCH, "commit_count": self.TEST_COMMIT_COUNT} 70 keywords = {'commit': self.TEST_COMMIT, 'branch': self.TEST_BRANCH, "commit_count": self.TEST_COMMIT_COUNT}
@@ -101,7 +108,7 @@ class GitArchiveTests(OESelftestTestCase):
101 url = 'git://git.yoctoproject.org/poky' 108 url = 'git://git.yoctoproject.org/poky'
102 path, git_obj = create_fake_repository(False, None, False) 109 path, git_obj = create_fake_repository(False, None, False)
103 110
104 tags = ga.get_tags(git_obj, pattern="yocto-*", url=url) 111 tags = ga.get_tags(git_obj, self.log, pattern="yocto-*", url=url)
105 """Test for some well established tags (released tags)""" 112 """Test for some well established tags (released tags)"""
106 self.assertIn("yocto-4.0", tags) 113 self.assertIn("yocto-4.0", tags)
107 self.assertIn("yocto-4.1", tags) 114 self.assertIn("yocto-4.1", tags)
@@ -114,7 +121,7 @@ class GitArchiveTests(OESelftestTestCase):
114 121
115 """Test for some well established tags (released tags)""" 122 """Test for some well established tags (released tags)"""
116 with self.assertRaises(GitError): 123 with self.assertRaises(GitError):
117 tags = ga.get_tags(git_obj, pattern="yocto-*") 124 tags = ga.get_tags(git_obj, self.log, pattern="yocto-*")
118 delete_fake_repository(path) 125 delete_fake_repository(path)
119 126
120 def test_get_tags_without_valid_remote_and_wrong_url(self): 127 def test_get_tags_without_valid_remote_and_wrong_url(self):
@@ -123,5 +130,5 @@ class GitArchiveTests(OESelftestTestCase):
123 130
124 """Test for some well established tags (released tags)""" 131 """Test for some well established tags (released tags)"""
125 with self.assertRaises(GitError): 132 with self.assertRaises(GitError):
126 tags = ga.get_tags(git_obj, pattern="yocto-*", url=url) 133 tags = ga.get_tags(git_obj, self.log, pattern="yocto-*", url=url)
127 delete_fake_repository(path) 134 delete_fake_repository(path)
diff --git a/meta/lib/oeqa/utils/gitarchive.py b/meta/lib/oeqa/utils/gitarchive.py
index 1a28a09efe..c15a44ce9e 100644
--- a/meta/lib/oeqa/utils/gitarchive.py
+++ b/meta/lib/oeqa/utils/gitarchive.py
@@ -100,7 +100,7 @@ def git_commit_data(repo, data_dir, branch, message, exclude, notes, log):
100 if os.path.exists(tmp_index): 100 if os.path.exists(tmp_index):
101 os.unlink(tmp_index) 101 os.unlink(tmp_index)
102 102
103def get_tags(repo, pattern=None, url=None): 103def get_tags(repo, log, pattern=None, url=None):
104 """ Fetch remote tags from current repository 104 """ Fetch remote tags from current repository
105 105
106 A pattern can be provided to filter returned tags list 106 A pattern can be provided to filter returned tags list
@@ -120,6 +120,7 @@ def get_tags(repo, pattern=None, url=None):
120 # If it fails, retry with repository url if one is provided 120 # If it fails, retry with repository url if one is provided
121 if not url: 121 if not url:
122 raise(e) 122 raise(e)
123 log.info("No remote repository configured, use provided url")
123 cmd = base_cmd.copy() 124 cmd = base_cmd.copy()
124 cmd.append(url) 125 cmd.append(url)
125 if pattern: 126 if pattern:
@@ -129,7 +130,7 @@ def get_tags(repo, pattern=None, url=None):
129 return ["".join(d.split()[1].split('/', 2)[2:]) for d in tags_refs.splitlines()] 130 return ["".join(d.split()[1].split('/', 2)[2:]) for d in tags_refs.splitlines()]
130 131
131def expand_tag_strings(repo, name_pattern, msg_subj_pattern, msg_body_pattern, 132def expand_tag_strings(repo, name_pattern, msg_subj_pattern, msg_body_pattern,
132 url, keywords): 133 url, log, keywords):
133 """Generate tag name and message, with support for running id number""" 134 """Generate tag name and message, with support for running id number"""
134 keyws = keywords.copy() 135 keyws = keywords.copy()
135 # Tag number is handled specially: if not defined, we autoincrement it 136 # Tag number is handled specially: if not defined, we autoincrement it
@@ -143,7 +144,7 @@ def expand_tag_strings(repo, name_pattern, msg_subj_pattern, msg_body_pattern,
143 tag_re = tag_re.format(tag_number='(?P<tag_number>[0-9]{1,5})') 144 tag_re = tag_re.format(tag_number='(?P<tag_number>[0-9]{1,5})')
144 145
145 keyws['tag_number'] = 0 146 keyws['tag_number'] = 0
146 for existing_tag in get_tags(repo, url=url): 147 for existing_tag in get_tags(repo, log, url=url):
147 match = re.match(tag_re, existing_tag) 148 match = re.match(tag_re, existing_tag)
148 149
149 if match and int(match.group('tag_number')) >= keyws['tag_number']: 150 if match and int(match.group('tag_number')) >= keyws['tag_number']:
@@ -171,7 +172,7 @@ def gitarchive(data_dir, git_dir, no_create, bare, commit_msg_subject, commit_ms
171 tag_name, tag_msg = expand_tag_strings(data_repo, tagname, 172 tag_name, tag_msg = expand_tag_strings(data_repo, tagname,
172 tag_msg_subject, 173 tag_msg_subject,
173 tag_msg_body, 174 tag_msg_body,
174 push, keywords) 175 push, log, keywords)
175 176
176 # Commit data 177 # Commit data
177 commit = git_commit_data(data_repo, data_dir, branch_name, 178 commit = git_commit_data(data_repo, data_dir, branch_name,
@@ -209,7 +210,7 @@ def get_test_runs(log, repo, tag_name, **kwargs):
209 210
210 # Get a list of all matching tags 211 # Get a list of all matching tags
211 tag_pattern = tag_name.format(**str_fields) 212 tag_pattern = tag_name.format(**str_fields)
212 tags = get_tags(repo, pattern=tag_pattern) 213 tags = get_tags(repo, log, pattern=tag_pattern)
213 log.debug("Found %d tags matching pattern '%s'", len(tags), tag_pattern) 214 log.debug("Found %d tags matching pattern '%s'", len(tags), tag_pattern)
214 215
215 # Parse undefined fields from tag names 216 # Parse undefined fields from tag names