... |
... |
@@ -22,6 +22,7 @@ |
22
|
22
|
|
23
|
23
|
import os
|
24
|
24
|
import pytest
|
|
25
|
+import shutil
|
25
|
26
|
|
26
|
27
|
from buildstream._exceptions import ErrorDomain
|
27
|
28
|
from buildstream import _yaml
|
... |
... |
@@ -408,3 +409,100 @@ def test_submodule_track_no_ref_or_track(cli, tmpdir, datafiles): |
408
|
409
|
result = cli.run(project=project, args=['show', 'target.bst'])
|
409
|
410
|
result.assert_main_error(ErrorDomain.SOURCE, "missing-track-and-ref")
|
410
|
411
|
result.assert_task_error(None, None)
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+@pytest.mark.skipif(HAVE_GIT is False, reason="git is not available")
|
|
415
|
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'template'))
|
|
416
|
+def test_overwrite_rogue_tag_multiple_remotes(cli, tmpdir, datafiles):
|
|
417
|
+ """When using multiple remotes in cache (i.e. when using aliases), we
|
|
418
|
+ need to make sure we override tags. This is not allowed to fetch
|
|
419
|
+ tags that were present from different origins
|
|
420
|
+ """
|
|
421
|
+
|
|
422
|
+ project = str(datafiles)
|
|
423
|
+
|
|
424
|
+ repofiles = os.path.join(str(tmpdir), 'repofiles')
|
|
425
|
+ os.makedirs(repofiles, exist_ok=True)
|
|
426
|
+ file0 = os.path.join(repofiles, 'file0')
|
|
427
|
+ with open(file0, 'w') as f:
|
|
428
|
+ f.write('test\n')
|
|
429
|
+
|
|
430
|
+ repo = create_repo('git', str(tmpdir))
|
|
431
|
+
|
|
432
|
+ top_commit = repo.create(repofiles)
|
|
433
|
+
|
|
434
|
+ repodir, reponame = os.path.split(repo.repo)
|
|
435
|
+ project_config = _yaml.load(os.path.join(project, 'project.conf'))
|
|
436
|
+ project_config['aliases'] = {
|
|
437
|
+ 'repo': 'http://example.com/'
|
|
438
|
+ }
|
|
439
|
+ project_config['mirrors'] = [
|
|
440
|
+ {
|
|
441
|
+ 'name': 'middle-earth',
|
|
442
|
+ 'aliases': {
|
|
443
|
+ 'repo': ['file://{}/'.format(repodir)]
|
|
444
|
+ }
|
|
445
|
+ }
|
|
446
|
+ ]
|
|
447
|
+ _yaml.dump(_yaml.node_sanitize(project_config), os.path.join(project, 'project.conf'))
|
|
448
|
+
|
|
449
|
+ repo.add_annotated_tag('tag', 'tag')
|
|
450
|
+
|
|
451
|
+ file1 = os.path.join(repofiles, 'file1')
|
|
452
|
+ with open(file1, 'w') as f:
|
|
453
|
+ f.write('test\n')
|
|
454
|
+
|
|
455
|
+ ref = repo.add_file(file1)
|
|
456
|
+
|
|
457
|
+ config = repo.source_config(ref=ref)
|
|
458
|
+ del config['track']
|
|
459
|
+ config['url'] = 'repo:{}'.format(reponame)
|
|
460
|
+
|
|
461
|
+ # Write out our test target
|
|
462
|
+ element = {
|
|
463
|
+ 'kind': 'import',
|
|
464
|
+ 'sources': [
|
|
465
|
+ config
|
|
466
|
+ ],
|
|
467
|
+ }
|
|
468
|
+ element_path = os.path.join(project, 'target.bst')
|
|
469
|
+ _yaml.dump(element, element_path)
|
|
470
|
+
|
|
471
|
+ result = cli.run(project=project, args=['build', 'target.bst'])
|
|
472
|
+ result.assert_success()
|
|
473
|
+
|
|
474
|
+ repo.checkout(top_commit)
|
|
475
|
+
|
|
476
|
+ file2 = os.path.join(repofiles, 'file2')
|
|
477
|
+ with open(file2, 'w') as f:
|
|
478
|
+ f.write('test\n')
|
|
479
|
+
|
|
480
|
+ new_ref = repo.add_file(file2)
|
|
481
|
+
|
|
482
|
+ repo.delete_tag('tag')
|
|
483
|
+ repo.add_annotated_tag('tag', 'tag')
|
|
484
|
+ repo.checkout('master')
|
|
485
|
+
|
|
486
|
+ otherpath = os.path.join(str(tmpdir), 'other_path')
|
|
487
|
+ shutil.copytree(repo.repo,
|
|
488
|
+ os.path.join(otherpath, 'repo'))
|
|
489
|
+ new_repo = create_repo('git', otherpath)
|
|
490
|
+
|
|
491
|
+ repodir, reponame = os.path.split(repo.repo)
|
|
492
|
+
|
|
493
|
+ _yaml.dump(_yaml.node_sanitize(project_config), os.path.join(project, 'project.conf'))
|
|
494
|
+
|
|
495
|
+ config = repo.source_config(ref=new_ref)
|
|
496
|
+ del config['track']
|
|
497
|
+ config['url'] = 'repo:{}'.format(reponame)
|
|
498
|
+
|
|
499
|
+ element = {
|
|
500
|
+ 'kind': 'import',
|
|
501
|
+ 'sources': [
|
|
502
|
+ config
|
|
503
|
+ ],
|
|
504
|
+ }
|
|
505
|
+ _yaml.dump(element, element_path)
|
|
506
|
+
|
|
507
|
+ result = cli.run(project=project, args=['build', 'target.bst'])
|
|
508
|
+ result.assert_success()
|