Merge ~nacc/git-ubuntu:importer-reimport-tags-lp1755247 into git-ubuntu:master

Proposed by Nish Aravamudan
Status: Merged
Merged at revision: 381bb37280773b85fe78d63545b0154fa28c17ae
Proposed branch: ~nacc/git-ubuntu:importer-reimport-tags-lp1755247
Merge into: git-ubuntu:master
Diff against target: 687 lines (+608/-1)
5 files modified
doc/SPECIFICATION.tags (+20/-0)
gitubuntu/git_repository.py (+55/-0)
gitubuntu/importer.py (+130/-0)
gitubuntu/repo_comparator.py (+56/-0)
gitubuntu/test_importer.py (+347/-1)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Andreas Hasenack Approve
Review via email: mp+342969@code.launchpad.net

Commit message

Make jenkins happy.

To post a comment you must log in.
Revision history for this message
Robie Basak (racb) wrote :

22:24 <rbasak> nacc: import/reimport creates an edge case in case of a package versioned "import" which is odd but I think may otherwise be valid (for a native package).
22:25 <rbasak> nacc: how about import/<version>, reimport/import/<version>, reimport/applied/<version>?
22:25 <rbasak> IOW, prefix reimport.
22:26 <rbasak> It's a rare edge case that requires it to exist at all, so flagging that it exists at the top level feels reasonable.

Specifically I'd like to avoid ever putting version strings into the same namespace as our specially named stuff, since that could collide. So whenever we have foo/<version>, we should forbid foo/bar where bar is anything else we define.

Revision history for this message
Nish Aravamudan (nacc) wrote :

Implemented as above.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:2b544822961a8c9b4d29a2909281ab0e44967289
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/393/
Executed test runs:
    SUCCESS: VM Setup
    SUCCESS: Build
    SUCCESS: Unit Tests
    SUCCESS: Integration Tests
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/393/rebuild

review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:7731c23f20e94a1c67bca06ee2cad0238afd4056
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/394/
Executed test runs:
    SUCCESS: VM Setup
    SUCCESS: Build
    SUCCESS: Unit Tests
    SUCCESS: Integration Tests
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/394/rebuild

review: Approve (continuous-integration)
Revision history for this message
Robie Basak (racb) wrote :

+1 to the new SPECIFICATION.tags from commit cf7f261.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

An inline comment about the test for creating applied/import tags, which probably falls into the category of test improvements. If you think it's fine to stay as it is, +1.

I would also suggest to rename the get_possible_{import,applied}_tags() method to get_existing_{import,applied}_tags(). Maybe by "possible" you mean "get me tags that could be import/applied" tags? Anyway, as you prefer, it's just a suggegstion.

review: Approve
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Thanks for the changes, +1 again

review: Approve
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:381bb37280773b85fe78d63545b0154fa28c17ae
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/395/
Executed test runs:
    SUCCESS: VM Setup
    SUCCESS: Build
    SUCCESS: Unit Tests
    SUCCESS: Integration Tests
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/395/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/doc/SPECIFICATION.tags b/doc/SPECIFICATION.tags
0new file mode 1006440new file mode 100644
index 0000000..a1e8750
--- /dev/null
+++ b/doc/SPECIFICATION.tags
@@ -0,0 +1,20 @@
1For the original bug reimport requiring this change, please see LP: #1755247.
2
3In the common case, we just need one tag: import/<version>, escaped according
4to DEP-14. In edge cases, we sometimes find that a publication has a different
5tree that must appear at a different place in the commit graph, so we need to
6reimport the same (changelog) "version" multiple times even though they have
7different contents. In this case, we use the following scheme:
8
9- By definition, import/<version> already exists since we only use this scheme
10 when it already exists and need to tag another import with the same version
11 string.
12- reimport/import/<version>/0 is created if it doesn’t already exist and is pointed to
13 the same commit as import/<version>. Assertion: if it does already exist, it
14 must point to import/<version> already; anything else is an importer error.
15- reimport/import/<version>/1 is created and points to the new commit as required. If
16 the /1 suffix already exists, use /2, falling back to /3, /4, etc.
17
18The same naming schema applies (no pun intended) to the patches-applied tags,
19which live under applied/ and reimport/applied/ rather than import/ and
20reimport/import/.
diff --git a/gitubuntu/git_repository.py b/gitubuntu/git_repository.py
index 94c8f54..9f1fdea 100644
--- a/gitubuntu/git_repository.py
+++ b/gitubuntu/git_repository.py
@@ -741,6 +741,30 @@ def git_dep14_tag(version):
741def import_tag(version, namespace):741def import_tag(version, namespace):
742 return '%s/import/%s' % (namespace, git_dep14_tag(version))742 return '%s/import/%s' % (namespace, git_dep14_tag(version))
743743
744def reimport_tag_prefix(version, namespace):
745 return '%s/reimport/import/%s' % (
746 namespace,
747 git_dep14_tag(version),
748 )
749
750def applied_reimport_tag_prefix(version, namespace):
751 return '%s/reimport/applied/%s' % (
752 namespace,
753 git_dep14_tag(version),
754 )
755
756def reimport_tag(version, namespace, reimport):
757 return '%s/%s' % (
758 reimport_tag_prefix(version, namespace),
759 reimport,
760 )
761
762def applied_reimport_tag(version, namespace, reimport):
763 return '%s/%s' % (
764 applied_reimport_tag_prefix(version, namespace),
765 reimport,
766 )
767
744def applied_tag(version, namespace):768def applied_tag(version, namespace):
745 return '%s/applied/%s' % (namespace, git_dep14_tag(version))769 return '%s/applied/%s' % (namespace, git_dep14_tag(version))
746770
@@ -1638,6 +1662,26 @@ class GitUbuntuRepository:
1638 def get_import_tag(self, version, namespace):1662 def get_import_tag(self, version, namespace):
1639 return self.get_tag_reference(import_tag(version, namespace))1663 return self.get_tag_reference(import_tag(version, namespace))
16401664
1665 def get_reimport_tag(self, version, namespace, reimport):
1666 return self.get_tag_reference(
1667 reimport_tag(version, namespace, reimport)
1668 )
1669
1670 def get_applied_reimport_tag(self, version, namespace, reimport):
1671 return self.get_tag_reference(
1672 applied_reimport_tag(version, namespace, reimport)
1673 )
1674
1675 def get_all_reimport_tags(self, version, namespace):
1676 return self.references_with_prefix(
1677 'refs/tags/%s' % reimport_tag_prefix(version, namespace)
1678 )
1679
1680 def get_all_applied_reimport_tags(self, version, namespace):
1681 return self.references_with_prefix(
1682 'refs/tags/%s' % applied_reimport_tag_prefix(version, namespace)
1683 )
1684
1641 def get_applied_tag(self, version, namespace):1685 def get_applied_tag(self, version, namespace):
1642 return self.get_tag_reference(applied_tag(version, namespace))1686 return self.get_tag_reference(applied_tag(version, namespace))
16431687
@@ -1650,6 +1694,17 @@ class GitUbuntuRepository:
1650 def get_orphan_tag(self, version, namespace):1694 def get_orphan_tag(self, version, namespace):
1651 return self.get_tag_reference(orphan_tag(version, namespace))1695 return self.get_tag_reference(orphan_tag(version, namespace))
16521696
1697 def create_tag(self, commit_hash, tag_name, tag_msg):
1698 self.git_run(
1699 [
1700 'tag',
1701 '-a',
1702 '-m', tag_msg,
1703 tag_name,
1704 commit_hash,
1705 ]
1706 )
1707
1653 def nearest_remote_branches(self, commit_hash, prefix=None,1708 def nearest_remote_branches(self, commit_hash, prefix=None,
1654 max_commits=1001709 max_commits=100
1655 ):1710 ):
diff --git a/gitubuntu/importer.py b/gitubuntu/importer.py
index 78fc3dc..a974af8 100644
--- a/gitubuntu/importer.py
+++ b/gitubuntu/importer.py
@@ -49,6 +49,8 @@ from gitubuntu.git_repository import (
49 orphan_tag,49 orphan_tag,
50 applied_tag,50 applied_tag,
51 import_tag,51 import_tag,
52 reimport_tag,
53 applied_reimport_tag,
52 upstream_tag,54 upstream_tag,
53 PristineTarError,55 PristineTarError,
54 is_dir_3_0_quilt,56 is_dir_3_0_quilt,
@@ -950,6 +952,34 @@ def parse_parentfile(parentfile, pkgname):
950952
951 return parent_overrides953 return parent_overrides
952954
955
956def get_existing_import_tags(repo, version, namespace):
957 existing_import_tag = repo.get_import_tag(version, namespace)
958 if existing_import_tag:
959 # check if there are reimports
960 existing_reimport_tags = repo.get_all_reimport_tags(version, namespace)
961 if existing_reimport_tags:
962 return existing_reimport_tags
963 else:
964 return [existing_import_tag]
965 return []
966
967
968def get_existing_applied_tags(repo, version, namespace):
969 existing_applied_tag = repo.get_applied_tag(version, namespace)
970 if existing_applied_tag:
971 # check if there are reimports
972 existing_applied_reimport_tags = repo.get_all_applied_reimport_tags(
973 version,
974 namespace,
975 )
976 if existing_applied_reimport_tags:
977 return existing_applied_reimport_tags
978 else:
979 return [existing_applied_tag]
980 return []
981
982
953def override_parents(parent_overrides, repo, spi, namespace):983def override_parents(parent_overrides, repo, spi, namespace):
954 """984 """
955 returns: (unapplied, applied) where both elements of the tuple are commit985 returns: (unapplied, applied) where both elements of the tuple are commit
@@ -1128,6 +1158,106 @@ def get_import_tag_msg():
1128 return 'git-ubuntu import v%s' % VERSION1158 return 'git-ubuntu import v%s' % VERSION
11291159
11301160
1161def create_applied_tag(repo, commit_hash, version, namespace):
1162 tag_msg = get_import_tag_msg()
1163
1164 existing_applied_tag = repo.get_applied_tag(version, namespace)
1165 if existing_applied_tag:
1166 base_applied_reimport_tag = repo.get_applied_reimport_tag(
1167 version,
1168 namespace,
1169 reimport=0,
1170 )
1171 if base_applied_reimport_tag:
1172 assert (
1173 base_applied_reimport_tag.peel(pygit2.Commit).id ==
1174 existing_applied_tag.peel(pygit2.Commit).id
1175 )
1176 else:
1177 repo.create_tag(
1178 str(existing_applied_tag.peel(pygit2.Commit).id),
1179 applied_reimport_tag(version, namespace, reimport=0),
1180 tag_msg,
1181 )
1182 num_existing_applied_reimports = len(
1183 repo.get_all_applied_reimport_tags(version, namespace)
1184 )
1185 assert not repo.get_applied_reimport_tag(
1186 version,
1187 namespace,
1188 reimport=num_existing_applied_reimports,
1189 )
1190 repo.create_tag(
1191 commit_hash,
1192 applied_reimport_tag(
1193 version,
1194 namespace,
1195 reimport=num_existing_applied_reimports,
1196 ),
1197 tag_msg,
1198 )
1199 return repo.get_applied_reimport_tag(
1200 version,
1201 namespace,
1202 reimport=num_existing_applied_reimports,
1203 )
1204 else:
1205 repo.create_tag(
1206 commit_hash,
1207 applied_tag(version, namespace),
1208 tag_msg,
1209 )
1210 return repo.get_applied_tag(version, namespace)
1211
1212
1213def create_import_tag(repo, commit_hash, version, namespace):
1214 tag_msg = get_import_tag_msg()
1215
1216 existing_import_tag = repo.get_import_tag(version, namespace)
1217 if existing_import_tag:
1218 base_reimport_tag = repo.get_reimport_tag(
1219 version,
1220 namespace,
1221 reimport=0,
1222 )
1223 if base_reimport_tag:
1224 assert (
1225 base_reimport_tag.peel(pygit2.Commit).id ==
1226 existing_import_tag.peel(pygit2.Commit).id
1227 )
1228 else:
1229 repo.create_tag(
1230 str(existing_import_tag.peel(pygit2.Commit).id),
1231 reimport_tag(version, namespace, reimport=0),
1232 tag_msg,
1233 )
1234 num_existing_reimports = len(
1235 repo.get_all_reimport_tags(version, namespace)
1236 )
1237 assert not repo.get_reimport_tag(
1238 version,
1239 namespace,
1240 reimport=num_existing_reimports,
1241 )
1242 repo.create_tag(
1243 commit_hash,
1244 reimport_tag(version, namespace, reimport=num_existing_reimports),
1245 tag_msg,
1246 )
1247 return repo.get_reimport_tag(
1248 version,
1249 namespace,
1250 reimport=num_existing_reimports,
1251 )
1252 else:
1253 repo.create_tag(
1254 commit_hash,
1255 import_tag(version, namespace),
1256 tag_msg,
1257 )
1258 return repo.get_import_tag(version, namespace)
1259
1260
1131# imports a package based upon source package information1261# imports a package based upon source package information
1132def import_unapplied_spi(1262def import_unapplied_spi(
1133 repo,1263 repo,
diff --git a/gitubuntu/repo_comparator.py b/gitubuntu/repo_comparator.py
1134new file mode 1006441264new file mode 100644
index 0000000..d65b431
--- /dev/null
+++ b/gitubuntu/repo_comparator.py
@@ -0,0 +1,56 @@
1from enum import Enum
2import tempfile
3
4import pygit2
5
6class RepoComparisonType(Enum):
7 Tree = 1
8 Commit = 2
9
10def equals(repoA, repoB, test_refs, comparison_type=RepoComparisonType.Commit):
11 """Compare two pygit2.Repository objects for equality
12
13 :param pygit2.Repository repoA The first repository to compare
14 :param gitubuntu.repo_builder.Repo repoB The second repository to compare
15 :param list(str) test_refs String reference names that should be
16 compared for equality
17 :param RepoComparisonType comparison_type What underlying Git object
18 should be compared for equality
19
20 :rtype bool
21 :returns Whether @repoA and @repoB contain the matching references and
22 reachable Git commits
23 """
24
25 test_refs = set(test_refs)
26
27 with tempfile.TemporaryDirectory() as tmp_dir:
28 pygit2_repoB = pygit2.init_repository(tmp_dir)
29 repoB.write(pygit2_repoB)
30
31 repoA_refs = set(repoA.listall_references())
32 if not test_refs.issubset(repoA_refs):
33 return False
34 repoA_refs = repoA_refs.intersection(test_refs)
35 repoB_refs = set(pygit2_repoB.listall_references())
36 if not test_refs.issubset(repoB_refs):
37 return False
38 repoB_refs = repoB_refs.intersection(test_refs)
39
40 if repoA_refs.symmetric_difference(repoB_refs):
41 return False
42
43 if comparison_type == RepoComparisonType.Tree:
44 peel_type = pygit2.Tree
45 elif comparison_type == RepoComparisonType.Commit:
46 peel_type = pygit2.Commit
47 else:
48 raise TypeError("Unknown RepoComparisonType: %r" % comparison_type)
49
50 for ref in repoA_refs:
51 refA_peeled = repoA.lookup_reference(ref).peel(peel_type)
52 refB_peeled = pygit2_repoB.lookup_reference(ref).peel(peel_type)
53 if str(refA_peeled.id) != str(refB_peeled.id):
54 return False
55
56 return True
diff --git a/gitubuntu/test_importer.py b/gitubuntu/test_importer.py
index 7fd5f45..a4e94d1 100644
--- a/gitubuntu/test_importer.py
+++ b/gitubuntu/test_importer.py
@@ -6,8 +6,8 @@ from unittest.mock import (
66
7import pytest7import pytest
88
9
10import gitubuntu.repo_builder as repo_builder9import gitubuntu.repo_builder as repo_builder
10import gitubuntu.repo_comparator as repo_comparator
11import gitubuntu.source_builder as source_builder11import gitubuntu.source_builder as source_builder
1212
13import gitubuntu.importer as target13import gitubuntu.importer as target
@@ -148,3 +148,349 @@ def test_get_import_commit_msg(
148 upload_parent_commit,148 upload_parent_commit,
149 unapplied_parent_commit,149 unapplied_parent_commit,
150 ) == expected150 ) == expected
151
152
153@pytest.mark.parametrize(
154 'input_data, expected', [
155 (
156 repo_builder.Repo(
157 commit_list=[],
158 branches={},
159 tags={},
160 ),
161 [],
162 ),
163 (
164 repo_builder.Repo(
165 commit_list=[],
166 branches={},
167 tags={
168 'importer/import/1-1': repo_builder.Commit(repo_builder.Tree({})),
169 },
170 ),
171 ['refs/tags/importer/import/1-1'],
172 ),
173 (
174 repo_builder.Repo(
175 commit_list=[
176 repo_builder.Commit(
177 tree=repo_builder.Tree({}),
178 name='import'
179 ),
180 repo_builder.Commit(
181 tree=repo_builder.Tree({}),
182 name='reimport1'
183 ),
184 ],
185 branches={},
186 tags={
187 'importer/import/1-1': repo_builder.Commit(repo_builder.Tree({})),
188 'importer/reimport/import/1-1/0': repo_builder.Commit(repo_builder.Tree({})),
189 'importer/reimport/import/1-1/1': repo_builder.Commit(repo_builder.Tree({})),
190 },
191 ),
192 [
193 'refs/tags/importer/reimport/import/1-1/0',
194 'refs/tags/importer/reimport/import/1-1/1',
195 ],
196 ),
197 ],
198)
199def test_get_existing_import_tags(repo, input_data, expected):
200 input_data.write(repo.raw_repo)
201
202 assert [
203 ref.name for ref in
204 target.get_existing_import_tags(repo, '1-1', 'importer')
205 ] == expected
206
207
208@pytest.mark.parametrize(
209 'input_data, expected', [
210 (
211 repo_builder.Repo(
212 commit_list=[],
213 branches={},
214 tags={},
215 ),
216 [],
217 ),
218 (
219 repo_builder.Repo(
220 commit_list=[],
221 branches={},
222 tags={
223 'importer/applied/1-1': repo_builder.Commit(repo_builder.Tree({})),
224 },
225 ),
226 ['refs/tags/importer/applied/1-1'],
227 ),
228 (
229 repo_builder.Repo(
230 commit_list=[
231 repo_builder.Commit(
232 tree=repo_builder.Tree({}),
233 name='applied'
234 ),
235 repo_builder.Commit(
236 tree=repo_builder.Tree({}),
237 name='reimport1'
238 ),
239 ],
240 branches={},
241 tags={
242 'importer/applied/1-1': repo_builder.Commit(repo_builder.Tree({})),
243 'importer/reimport/applied/1-1/0': repo_builder.Commit(repo_builder.Tree({})),
244 'importer/reimport/applied/1-1/1': repo_builder.Commit(repo_builder.Tree({})),
245 },
246 ),
247 [
248 'refs/tags/importer/reimport/applied/1-1/0',
249 'refs/tags/importer/reimport/applied/1-1/1',
250 ],
251 ),
252 ],
253)
254def test_get_existing_applied_tags(repo, input_data, expected):
255 input_data.write(repo.raw_repo)
256
257 assert [
258 ref.name for ref in
259 target.get_existing_applied_tags(repo, '1-1', 'importer')
260 ] == expected
261
262
263@pytest.mark.parametrize(
264 'input_data, expected_changes, test_refs', [
265 (
266 repo_builder.Repo(
267 commit_list=[],
268 branches={},
269 tags={},
270 ),
271 {
272 'commit_list_to_add': [
273 repo_builder.Commit(
274 tree=repo_builder.Tree({}),
275 name='import'
276 ),
277 ],
278 'tags_to_add': {
279 'importer/import/1-1': repo_builder.Placeholder('import'),
280 },
281 'branches_to_update': {
282 },
283 },
284 [
285 'refs/tags/importer/import/1-1',
286 ],
287 ),
288 (
289 repo_builder.Repo(
290 commit_list=[
291 repo_builder.Commit(
292 tree=repo_builder.Tree({}),
293 name='import'
294 ),
295 ],
296 branches={},
297 tags={
298 'importer/import/1-1': repo_builder.Placeholder('import'),
299 },
300 ),
301 {
302 'commit_list_to_add': [
303 repo_builder.Commit(
304 tree=repo_builder.Tree({}),
305 name='reimport'
306 ),
307 ],
308 'tags_to_add': {
309 'importer/reimport/import/1-1/0': repo_builder.Placeholder('import'),
310 'importer/reimport/import/1-1/1': repo_builder.Placeholder('reimport'),
311 },
312 'branches_to_update': {
313 },
314 },
315 [
316 'refs/tags/importer/import/1-1',
317 'refs/tags/importer/reimport/import/1-1/0',
318 'refs/tags/importer/reimport/import/1-1/1',
319 ],
320 ),
321 (
322 repo_builder.Repo(
323 commit_list=[
324 repo_builder.Commit(
325 tree=repo_builder.Tree({}),
326 name='import'
327 ),
328 repo_builder.Commit(
329 tree=repo_builder.Tree({}),
330 name='reimport1'
331 ),
332 ],
333 branches={},
334 tags={
335 'importer/import/1-1': repo_builder.Placeholder('import'),
336 'importer/reimport/import/1-1/0': repo_builder.Placeholder('import'),
337 'importer/reimport/import/1-1/1': repo_builder.Placeholder('reimport1'),
338 },
339 ),
340 {
341 'commit_list_to_add': [
342 repo_builder.Commit(
343 tree=repo_builder.Tree({}),
344 name='reimport2'
345 ),
346 ],
347 'tags_to_add': {
348 'importer/reimport/import/1-1/2': repo_builder.Placeholder('reimport2'),
349 },
350 'branches_to_update': {
351 },
352 },
353 [
354 'refs/tags/importer/import/1-1',
355 'refs/tags/importer/reimport/import/1-1/0',
356 'refs/tags/importer/reimport/import/1-1/1',
357 'refs/tags/importer/reimport/import/1-1/2',
358 ],
359 ),
360 ],
361)
362def test_create_import_tag(repo, input_data, expected_changes, test_refs):
363 publish_commit_str = str(repo.raw_repo.get(repo_builder.Commit(
364 repo_builder.Tree({})
365 ).write(repo.raw_repo)).peel(pygit2.Commit).id)
366
367 # copy before write, so that placeholders are still present
368 expected_result = input_data.copy(**expected_changes)
369
370 input_data.write(repo.raw_repo)
371
372 target.create_import_tag(repo, publish_commit_str, '1-1', 'importer')
373
374 assert repo_comparator.equals(
375 repoA=repo.raw_repo,
376 repoB=expected_result,
377 test_refs=test_refs,
378 )
379
380
381@pytest.mark.parametrize(
382 'input_data, expected_changes, test_refs', [
383 (
384 repo_builder.Repo(
385 commit_list=[],
386 branches={},
387 tags={},
388 ),
389 {
390 'commit_list_to_add': [
391 repo_builder.Commit(
392 tree=repo_builder.Tree({}),
393 name='import'
394 ),
395 ],
396 'tags_to_add': {
397 'importer/applied/1-1': repo_builder.Placeholder('import'),
398 },
399 'branches_to_update': {
400 },
401 },
402 [
403 'refs/tags/importer/applied/1-1',
404 ],
405 ),
406 (
407 repo_builder.Repo(
408 commit_list=[
409 repo_builder.Commit(
410 tree=repo_builder.Tree({}),
411 name='import'
412 ),
413 ],
414 branches={},
415 tags={
416 'importer/applied/1-1': repo_builder.Placeholder('import'),
417 },
418 ),
419 {
420 'commit_list_to_add': [
421 repo_builder.Commit(
422 tree=repo_builder.Tree({}),
423 name='reimport'
424 ),
425 ],
426 'tags_to_add': {
427 'importer/reimport/applied/1-1/0': repo_builder.Placeholder('import'),
428 'importer/reimport/applied/1-1/1': repo_builder.Placeholder('reimport'),
429 },
430 'branches_to_update': {
431 },
432 },
433 [
434 'refs/tags/importer/applied/1-1',
435 'refs/tags/importer/reimport/applied/1-1/0',
436 'refs/tags/importer/reimport/applied/1-1/1',
437 ],
438 ),
439 (
440 repo_builder.Repo(
441 commit_list=[
442 repo_builder.Commit(
443 tree=repo_builder.Tree({}),
444 name='import'
445 ),
446 repo_builder.Commit(
447 tree=repo_builder.Tree({}),
448 name='reimport1'
449 ),
450 ],
451 branches={},
452 tags={
453 'importer/applied/1-1': repo_builder.Placeholder('import'),
454 'importer/reimport/applied/1-1/0': repo_builder.Placeholder('import'),
455 'importer/reimport/applied/1-1/1': repo_builder.Placeholder('reimport1'),
456 },
457 ),
458 {
459 'commit_list_to_add': [
460 repo_builder.Commit(
461 tree=repo_builder.Tree({}),
462 name='reimport2'
463 ),
464 ],
465 'tags_to_add': {
466 'importer/reimport/applied/1-1/2': repo_builder.Placeholder('reimport2'),
467 },
468 'branches_to_update': {
469 },
470 },
471 [
472 'refs/tags/importer/applied/1-1',
473 'refs/tags/importer/reimport/applied/1-1/0',
474 'refs/tags/importer/reimport/applied/1-1/1',
475 'refs/tags/importer/reimport/applied/1-1/2',
476 ],
477 ),
478 ],
479)
480def test_create_applied_tag(repo, input_data, expected_changes, test_refs):
481 publish_commit_str = str(repo.raw_repo.get(repo_builder.Commit(
482 repo_builder.Tree({})
483 ).write(repo.raw_repo)).peel(pygit2.Commit).id)
484
485 # copy before write, so that placeholders are still present
486 expected_result = input_data.copy(**expected_changes)
487
488 input_data.write(repo.raw_repo)
489
490 target.create_applied_tag(repo, publish_commit_str, '1-1', 'importer')
491
492 assert repo_comparator.equals(
493 repoA=repo.raw_repo,
494 repoB=expected_result,
495 test_refs=test_refs,
496 )

Subscribers

People subscribed via source and target branches