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
1diff --git a/doc/SPECIFICATION.tags b/doc/SPECIFICATION.tags
2new file mode 100644
3index 0000000..a1e8750
4--- /dev/null
5+++ b/doc/SPECIFICATION.tags
6@@ -0,0 +1,20 @@
7+For the original bug reimport requiring this change, please see LP: #1755247.
8+
9+In the common case, we just need one tag: import/<version>, escaped according
10+to DEP-14. In edge cases, we sometimes find that a publication has a different
11+tree that must appear at a different place in the commit graph, so we need to
12+reimport the same (changelog) "version" multiple times even though they have
13+different contents. In this case, we use the following scheme:
14+
15+- By definition, import/<version> already exists since we only use this scheme
16+ when it already exists and need to tag another import with the same version
17+ string.
18+- reimport/import/<version>/0 is created if it doesn’t already exist and is pointed to
19+ the same commit as import/<version>. Assertion: if it does already exist, it
20+ must point to import/<version> already; anything else is an importer error.
21+- reimport/import/<version>/1 is created and points to the new commit as required. If
22+ the /1 suffix already exists, use /2, falling back to /3, /4, etc.
23+
24+The same naming schema applies (no pun intended) to the patches-applied tags,
25+which live under applied/ and reimport/applied/ rather than import/ and
26+reimport/import/.
27diff --git a/gitubuntu/git_repository.py b/gitubuntu/git_repository.py
28index 94c8f54..9f1fdea 100644
29--- a/gitubuntu/git_repository.py
30+++ b/gitubuntu/git_repository.py
31@@ -741,6 +741,30 @@ def git_dep14_tag(version):
32 def import_tag(version, namespace):
33 return '%s/import/%s' % (namespace, git_dep14_tag(version))
34
35+def reimport_tag_prefix(version, namespace):
36+ return '%s/reimport/import/%s' % (
37+ namespace,
38+ git_dep14_tag(version),
39+ )
40+
41+def applied_reimport_tag_prefix(version, namespace):
42+ return '%s/reimport/applied/%s' % (
43+ namespace,
44+ git_dep14_tag(version),
45+ )
46+
47+def reimport_tag(version, namespace, reimport):
48+ return '%s/%s' % (
49+ reimport_tag_prefix(version, namespace),
50+ reimport,
51+ )
52+
53+def applied_reimport_tag(version, namespace, reimport):
54+ return '%s/%s' % (
55+ applied_reimport_tag_prefix(version, namespace),
56+ reimport,
57+ )
58+
59 def applied_tag(version, namespace):
60 return '%s/applied/%s' % (namespace, git_dep14_tag(version))
61
62@@ -1638,6 +1662,26 @@ class GitUbuntuRepository:
63 def get_import_tag(self, version, namespace):
64 return self.get_tag_reference(import_tag(version, namespace))
65
66+ def get_reimport_tag(self, version, namespace, reimport):
67+ return self.get_tag_reference(
68+ reimport_tag(version, namespace, reimport)
69+ )
70+
71+ def get_applied_reimport_tag(self, version, namespace, reimport):
72+ return self.get_tag_reference(
73+ applied_reimport_tag(version, namespace, reimport)
74+ )
75+
76+ def get_all_reimport_tags(self, version, namespace):
77+ return self.references_with_prefix(
78+ 'refs/tags/%s' % reimport_tag_prefix(version, namespace)
79+ )
80+
81+ def get_all_applied_reimport_tags(self, version, namespace):
82+ return self.references_with_prefix(
83+ 'refs/tags/%s' % applied_reimport_tag_prefix(version, namespace)
84+ )
85+
86 def get_applied_tag(self, version, namespace):
87 return self.get_tag_reference(applied_tag(version, namespace))
88
89@@ -1650,6 +1694,17 @@ class GitUbuntuRepository:
90 def get_orphan_tag(self, version, namespace):
91 return self.get_tag_reference(orphan_tag(version, namespace))
92
93+ def create_tag(self, commit_hash, tag_name, tag_msg):
94+ self.git_run(
95+ [
96+ 'tag',
97+ '-a',
98+ '-m', tag_msg,
99+ tag_name,
100+ commit_hash,
101+ ]
102+ )
103+
104 def nearest_remote_branches(self, commit_hash, prefix=None,
105 max_commits=100
106 ):
107diff --git a/gitubuntu/importer.py b/gitubuntu/importer.py
108index 78fc3dc..a974af8 100644
109--- a/gitubuntu/importer.py
110+++ b/gitubuntu/importer.py
111@@ -49,6 +49,8 @@ from gitubuntu.git_repository import (
112 orphan_tag,
113 applied_tag,
114 import_tag,
115+ reimport_tag,
116+ applied_reimport_tag,
117 upstream_tag,
118 PristineTarError,
119 is_dir_3_0_quilt,
120@@ -950,6 +952,34 @@ def parse_parentfile(parentfile, pkgname):
121
122 return parent_overrides
123
124+
125+def get_existing_import_tags(repo, version, namespace):
126+ existing_import_tag = repo.get_import_tag(version, namespace)
127+ if existing_import_tag:
128+ # check if there are reimports
129+ existing_reimport_tags = repo.get_all_reimport_tags(version, namespace)
130+ if existing_reimport_tags:
131+ return existing_reimport_tags
132+ else:
133+ return [existing_import_tag]
134+ return []
135+
136+
137+def get_existing_applied_tags(repo, version, namespace):
138+ existing_applied_tag = repo.get_applied_tag(version, namespace)
139+ if existing_applied_tag:
140+ # check if there are reimports
141+ existing_applied_reimport_tags = repo.get_all_applied_reimport_tags(
142+ version,
143+ namespace,
144+ )
145+ if existing_applied_reimport_tags:
146+ return existing_applied_reimport_tags
147+ else:
148+ return [existing_applied_tag]
149+ return []
150+
151+
152 def override_parents(parent_overrides, repo, spi, namespace):
153 """
154 returns: (unapplied, applied) where both elements of the tuple are commit
155@@ -1128,6 +1158,106 @@ def get_import_tag_msg():
156 return 'git-ubuntu import v%s' % VERSION
157
158
159+def create_applied_tag(repo, commit_hash, version, namespace):
160+ tag_msg = get_import_tag_msg()
161+
162+ existing_applied_tag = repo.get_applied_tag(version, namespace)
163+ if existing_applied_tag:
164+ base_applied_reimport_tag = repo.get_applied_reimport_tag(
165+ version,
166+ namespace,
167+ reimport=0,
168+ )
169+ if base_applied_reimport_tag:
170+ assert (
171+ base_applied_reimport_tag.peel(pygit2.Commit).id ==
172+ existing_applied_tag.peel(pygit2.Commit).id
173+ )
174+ else:
175+ repo.create_tag(
176+ str(existing_applied_tag.peel(pygit2.Commit).id),
177+ applied_reimport_tag(version, namespace, reimport=0),
178+ tag_msg,
179+ )
180+ num_existing_applied_reimports = len(
181+ repo.get_all_applied_reimport_tags(version, namespace)
182+ )
183+ assert not repo.get_applied_reimport_tag(
184+ version,
185+ namespace,
186+ reimport=num_existing_applied_reimports,
187+ )
188+ repo.create_tag(
189+ commit_hash,
190+ applied_reimport_tag(
191+ version,
192+ namespace,
193+ reimport=num_existing_applied_reimports,
194+ ),
195+ tag_msg,
196+ )
197+ return repo.get_applied_reimport_tag(
198+ version,
199+ namespace,
200+ reimport=num_existing_applied_reimports,
201+ )
202+ else:
203+ repo.create_tag(
204+ commit_hash,
205+ applied_tag(version, namespace),
206+ tag_msg,
207+ )
208+ return repo.get_applied_tag(version, namespace)
209+
210+
211+def create_import_tag(repo, commit_hash, version, namespace):
212+ tag_msg = get_import_tag_msg()
213+
214+ existing_import_tag = repo.get_import_tag(version, namespace)
215+ if existing_import_tag:
216+ base_reimport_tag = repo.get_reimport_tag(
217+ version,
218+ namespace,
219+ reimport=0,
220+ )
221+ if base_reimport_tag:
222+ assert (
223+ base_reimport_tag.peel(pygit2.Commit).id ==
224+ existing_import_tag.peel(pygit2.Commit).id
225+ )
226+ else:
227+ repo.create_tag(
228+ str(existing_import_tag.peel(pygit2.Commit).id),
229+ reimport_tag(version, namespace, reimport=0),
230+ tag_msg,
231+ )
232+ num_existing_reimports = len(
233+ repo.get_all_reimport_tags(version, namespace)
234+ )
235+ assert not repo.get_reimport_tag(
236+ version,
237+ namespace,
238+ reimport=num_existing_reimports,
239+ )
240+ repo.create_tag(
241+ commit_hash,
242+ reimport_tag(version, namespace, reimport=num_existing_reimports),
243+ tag_msg,
244+ )
245+ return repo.get_reimport_tag(
246+ version,
247+ namespace,
248+ reimport=num_existing_reimports,
249+ )
250+ else:
251+ repo.create_tag(
252+ commit_hash,
253+ import_tag(version, namespace),
254+ tag_msg,
255+ )
256+ return repo.get_import_tag(version, namespace)
257+
258+
259 # imports a package based upon source package information
260 def import_unapplied_spi(
261 repo,
262diff --git a/gitubuntu/repo_comparator.py b/gitubuntu/repo_comparator.py
263new file mode 100644
264index 0000000..d65b431
265--- /dev/null
266+++ b/gitubuntu/repo_comparator.py
267@@ -0,0 +1,56 @@
268+from enum import Enum
269+import tempfile
270+
271+import pygit2
272+
273+class RepoComparisonType(Enum):
274+ Tree = 1
275+ Commit = 2
276+
277+def equals(repoA, repoB, test_refs, comparison_type=RepoComparisonType.Commit):
278+ """Compare two pygit2.Repository objects for equality
279+
280+ :param pygit2.Repository repoA The first repository to compare
281+ :param gitubuntu.repo_builder.Repo repoB The second repository to compare
282+ :param list(str) test_refs String reference names that should be
283+ compared for equality
284+ :param RepoComparisonType comparison_type What underlying Git object
285+ should be compared for equality
286+
287+ :rtype bool
288+ :returns Whether @repoA and @repoB contain the matching references and
289+ reachable Git commits
290+ """
291+
292+ test_refs = set(test_refs)
293+
294+ with tempfile.TemporaryDirectory() as tmp_dir:
295+ pygit2_repoB = pygit2.init_repository(tmp_dir)
296+ repoB.write(pygit2_repoB)
297+
298+ repoA_refs = set(repoA.listall_references())
299+ if not test_refs.issubset(repoA_refs):
300+ return False
301+ repoA_refs = repoA_refs.intersection(test_refs)
302+ repoB_refs = set(pygit2_repoB.listall_references())
303+ if not test_refs.issubset(repoB_refs):
304+ return False
305+ repoB_refs = repoB_refs.intersection(test_refs)
306+
307+ if repoA_refs.symmetric_difference(repoB_refs):
308+ return False
309+
310+ if comparison_type == RepoComparisonType.Tree:
311+ peel_type = pygit2.Tree
312+ elif comparison_type == RepoComparisonType.Commit:
313+ peel_type = pygit2.Commit
314+ else:
315+ raise TypeError("Unknown RepoComparisonType: %r" % comparison_type)
316+
317+ for ref in repoA_refs:
318+ refA_peeled = repoA.lookup_reference(ref).peel(peel_type)
319+ refB_peeled = pygit2_repoB.lookup_reference(ref).peel(peel_type)
320+ if str(refA_peeled.id) != str(refB_peeled.id):
321+ return False
322+
323+ return True
324diff --git a/gitubuntu/test_importer.py b/gitubuntu/test_importer.py
325index 7fd5f45..a4e94d1 100644
326--- a/gitubuntu/test_importer.py
327+++ b/gitubuntu/test_importer.py
328@@ -6,8 +6,8 @@ from unittest.mock import (
329
330 import pytest
331
332-
333 import gitubuntu.repo_builder as repo_builder
334+import gitubuntu.repo_comparator as repo_comparator
335 import gitubuntu.source_builder as source_builder
336
337 import gitubuntu.importer as target
338@@ -148,3 +148,349 @@ def test_get_import_commit_msg(
339 upload_parent_commit,
340 unapplied_parent_commit,
341 ) == expected
342+
343+
344+@pytest.mark.parametrize(
345+ 'input_data, expected', [
346+ (
347+ repo_builder.Repo(
348+ commit_list=[],
349+ branches={},
350+ tags={},
351+ ),
352+ [],
353+ ),
354+ (
355+ repo_builder.Repo(
356+ commit_list=[],
357+ branches={},
358+ tags={
359+ 'importer/import/1-1': repo_builder.Commit(repo_builder.Tree({})),
360+ },
361+ ),
362+ ['refs/tags/importer/import/1-1'],
363+ ),
364+ (
365+ repo_builder.Repo(
366+ commit_list=[
367+ repo_builder.Commit(
368+ tree=repo_builder.Tree({}),
369+ name='import'
370+ ),
371+ repo_builder.Commit(
372+ tree=repo_builder.Tree({}),
373+ name='reimport1'
374+ ),
375+ ],
376+ branches={},
377+ tags={
378+ 'importer/import/1-1': repo_builder.Commit(repo_builder.Tree({})),
379+ 'importer/reimport/import/1-1/0': repo_builder.Commit(repo_builder.Tree({})),
380+ 'importer/reimport/import/1-1/1': repo_builder.Commit(repo_builder.Tree({})),
381+ },
382+ ),
383+ [
384+ 'refs/tags/importer/reimport/import/1-1/0',
385+ 'refs/tags/importer/reimport/import/1-1/1',
386+ ],
387+ ),
388+ ],
389+)
390+def test_get_existing_import_tags(repo, input_data, expected):
391+ input_data.write(repo.raw_repo)
392+
393+ assert [
394+ ref.name for ref in
395+ target.get_existing_import_tags(repo, '1-1', 'importer')
396+ ] == expected
397+
398+
399+@pytest.mark.parametrize(
400+ 'input_data, expected', [
401+ (
402+ repo_builder.Repo(
403+ commit_list=[],
404+ branches={},
405+ tags={},
406+ ),
407+ [],
408+ ),
409+ (
410+ repo_builder.Repo(
411+ commit_list=[],
412+ branches={},
413+ tags={
414+ 'importer/applied/1-1': repo_builder.Commit(repo_builder.Tree({})),
415+ },
416+ ),
417+ ['refs/tags/importer/applied/1-1'],
418+ ),
419+ (
420+ repo_builder.Repo(
421+ commit_list=[
422+ repo_builder.Commit(
423+ tree=repo_builder.Tree({}),
424+ name='applied'
425+ ),
426+ repo_builder.Commit(
427+ tree=repo_builder.Tree({}),
428+ name='reimport1'
429+ ),
430+ ],
431+ branches={},
432+ tags={
433+ 'importer/applied/1-1': repo_builder.Commit(repo_builder.Tree({})),
434+ 'importer/reimport/applied/1-1/0': repo_builder.Commit(repo_builder.Tree({})),
435+ 'importer/reimport/applied/1-1/1': repo_builder.Commit(repo_builder.Tree({})),
436+ },
437+ ),
438+ [
439+ 'refs/tags/importer/reimport/applied/1-1/0',
440+ 'refs/tags/importer/reimport/applied/1-1/1',
441+ ],
442+ ),
443+ ],
444+)
445+def test_get_existing_applied_tags(repo, input_data, expected):
446+ input_data.write(repo.raw_repo)
447+
448+ assert [
449+ ref.name for ref in
450+ target.get_existing_applied_tags(repo, '1-1', 'importer')
451+ ] == expected
452+
453+
454+@pytest.mark.parametrize(
455+ 'input_data, expected_changes, test_refs', [
456+ (
457+ repo_builder.Repo(
458+ commit_list=[],
459+ branches={},
460+ tags={},
461+ ),
462+ {
463+ 'commit_list_to_add': [
464+ repo_builder.Commit(
465+ tree=repo_builder.Tree({}),
466+ name='import'
467+ ),
468+ ],
469+ 'tags_to_add': {
470+ 'importer/import/1-1': repo_builder.Placeholder('import'),
471+ },
472+ 'branches_to_update': {
473+ },
474+ },
475+ [
476+ 'refs/tags/importer/import/1-1',
477+ ],
478+ ),
479+ (
480+ repo_builder.Repo(
481+ commit_list=[
482+ repo_builder.Commit(
483+ tree=repo_builder.Tree({}),
484+ name='import'
485+ ),
486+ ],
487+ branches={},
488+ tags={
489+ 'importer/import/1-1': repo_builder.Placeholder('import'),
490+ },
491+ ),
492+ {
493+ 'commit_list_to_add': [
494+ repo_builder.Commit(
495+ tree=repo_builder.Tree({}),
496+ name='reimport'
497+ ),
498+ ],
499+ 'tags_to_add': {
500+ 'importer/reimport/import/1-1/0': repo_builder.Placeholder('import'),
501+ 'importer/reimport/import/1-1/1': repo_builder.Placeholder('reimport'),
502+ },
503+ 'branches_to_update': {
504+ },
505+ },
506+ [
507+ 'refs/tags/importer/import/1-1',
508+ 'refs/tags/importer/reimport/import/1-1/0',
509+ 'refs/tags/importer/reimport/import/1-1/1',
510+ ],
511+ ),
512+ (
513+ repo_builder.Repo(
514+ commit_list=[
515+ repo_builder.Commit(
516+ tree=repo_builder.Tree({}),
517+ name='import'
518+ ),
519+ repo_builder.Commit(
520+ tree=repo_builder.Tree({}),
521+ name='reimport1'
522+ ),
523+ ],
524+ branches={},
525+ tags={
526+ 'importer/import/1-1': repo_builder.Placeholder('import'),
527+ 'importer/reimport/import/1-1/0': repo_builder.Placeholder('import'),
528+ 'importer/reimport/import/1-1/1': repo_builder.Placeholder('reimport1'),
529+ },
530+ ),
531+ {
532+ 'commit_list_to_add': [
533+ repo_builder.Commit(
534+ tree=repo_builder.Tree({}),
535+ name='reimport2'
536+ ),
537+ ],
538+ 'tags_to_add': {
539+ 'importer/reimport/import/1-1/2': repo_builder.Placeholder('reimport2'),
540+ },
541+ 'branches_to_update': {
542+ },
543+ },
544+ [
545+ 'refs/tags/importer/import/1-1',
546+ 'refs/tags/importer/reimport/import/1-1/0',
547+ 'refs/tags/importer/reimport/import/1-1/1',
548+ 'refs/tags/importer/reimport/import/1-1/2',
549+ ],
550+ ),
551+ ],
552+)
553+def test_create_import_tag(repo, input_data, expected_changes, test_refs):
554+ publish_commit_str = str(repo.raw_repo.get(repo_builder.Commit(
555+ repo_builder.Tree({})
556+ ).write(repo.raw_repo)).peel(pygit2.Commit).id)
557+
558+ # copy before write, so that placeholders are still present
559+ expected_result = input_data.copy(**expected_changes)
560+
561+ input_data.write(repo.raw_repo)
562+
563+ target.create_import_tag(repo, publish_commit_str, '1-1', 'importer')
564+
565+ assert repo_comparator.equals(
566+ repoA=repo.raw_repo,
567+ repoB=expected_result,
568+ test_refs=test_refs,
569+ )
570+
571+
572+@pytest.mark.parametrize(
573+ 'input_data, expected_changes, test_refs', [
574+ (
575+ repo_builder.Repo(
576+ commit_list=[],
577+ branches={},
578+ tags={},
579+ ),
580+ {
581+ 'commit_list_to_add': [
582+ repo_builder.Commit(
583+ tree=repo_builder.Tree({}),
584+ name='import'
585+ ),
586+ ],
587+ 'tags_to_add': {
588+ 'importer/applied/1-1': repo_builder.Placeholder('import'),
589+ },
590+ 'branches_to_update': {
591+ },
592+ },
593+ [
594+ 'refs/tags/importer/applied/1-1',
595+ ],
596+ ),
597+ (
598+ repo_builder.Repo(
599+ commit_list=[
600+ repo_builder.Commit(
601+ tree=repo_builder.Tree({}),
602+ name='import'
603+ ),
604+ ],
605+ branches={},
606+ tags={
607+ 'importer/applied/1-1': repo_builder.Placeholder('import'),
608+ },
609+ ),
610+ {
611+ 'commit_list_to_add': [
612+ repo_builder.Commit(
613+ tree=repo_builder.Tree({}),
614+ name='reimport'
615+ ),
616+ ],
617+ 'tags_to_add': {
618+ 'importer/reimport/applied/1-1/0': repo_builder.Placeholder('import'),
619+ 'importer/reimport/applied/1-1/1': repo_builder.Placeholder('reimport'),
620+ },
621+ 'branches_to_update': {
622+ },
623+ },
624+ [
625+ 'refs/tags/importer/applied/1-1',
626+ 'refs/tags/importer/reimport/applied/1-1/0',
627+ 'refs/tags/importer/reimport/applied/1-1/1',
628+ ],
629+ ),
630+ (
631+ repo_builder.Repo(
632+ commit_list=[
633+ repo_builder.Commit(
634+ tree=repo_builder.Tree({}),
635+ name='import'
636+ ),
637+ repo_builder.Commit(
638+ tree=repo_builder.Tree({}),
639+ name='reimport1'
640+ ),
641+ ],
642+ branches={},
643+ tags={
644+ 'importer/applied/1-1': repo_builder.Placeholder('import'),
645+ 'importer/reimport/applied/1-1/0': repo_builder.Placeholder('import'),
646+ 'importer/reimport/applied/1-1/1': repo_builder.Placeholder('reimport1'),
647+ },
648+ ),
649+ {
650+ 'commit_list_to_add': [
651+ repo_builder.Commit(
652+ tree=repo_builder.Tree({}),
653+ name='reimport2'
654+ ),
655+ ],
656+ 'tags_to_add': {
657+ 'importer/reimport/applied/1-1/2': repo_builder.Placeholder('reimport2'),
658+ },
659+ 'branches_to_update': {
660+ },
661+ },
662+ [
663+ 'refs/tags/importer/applied/1-1',
664+ 'refs/tags/importer/reimport/applied/1-1/0',
665+ 'refs/tags/importer/reimport/applied/1-1/1',
666+ 'refs/tags/importer/reimport/applied/1-1/2',
667+ ],
668+ ),
669+ ],
670+)
671+def test_create_applied_tag(repo, input_data, expected_changes, test_refs):
672+ publish_commit_str = str(repo.raw_repo.get(repo_builder.Commit(
673+ repo_builder.Tree({})
674+ ).write(repo.raw_repo)).peel(pygit2.Commit).id)
675+
676+ # copy before write, so that placeholders are still present
677+ expected_result = input_data.copy(**expected_changes)
678+
679+ input_data.write(repo.raw_repo)
680+
681+ target.create_applied_tag(repo, publish_commit_str, '1-1', 'importer')
682+
683+ assert repo_comparator.equals(
684+ repoA=repo.raw_repo,
685+ repoB=expected_result,
686+ test_refs=test_refs,
687+ )

Subscribers

People subscribed via source and target branches