... |
... |
@@ -23,6 +23,7 @@ |
23
|
23
|
import os
|
24
|
24
|
import pytest
|
25
|
25
|
import subprocess
|
|
26
|
+import shutil
|
26
|
27
|
|
27
|
28
|
from buildstream._exceptions import ErrorDomain
|
28
|
29
|
from buildstream import _yaml
|
... |
... |
@@ -920,3 +921,100 @@ def test_default_do_not_track_tags(cli, tmpdir, datafiles): |
920
|
921
|
|
921
|
922
|
element = _yaml.load(element_path)
|
922
|
923
|
assert 'tags' not in element['sources'][0]
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+@pytest.mark.skipif(HAVE_GIT is False, reason="git is not available")
|
|
927
|
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'template'))
|
|
928
|
+def test_overwrite_rogue_tag_multiple_remotes(cli, tmpdir, datafiles):
|
|
929
|
+ """When using multiple remotes in cache (i.e. when using aliases), we
|
|
930
|
+ need to make sure we override tags. This is not allowed to fetch
|
|
931
|
+ tags that were present from different origins
|
|
932
|
+ """
|
|
933
|
+
|
|
934
|
+ project = str(datafiles)
|
|
935
|
+
|
|
936
|
+ repofiles = os.path.join(str(tmpdir), 'repofiles')
|
|
937
|
+ os.makedirs(repofiles, exist_ok=True)
|
|
938
|
+ file0 = os.path.join(repofiles, 'file0')
|
|
939
|
+ with open(file0, 'w') as f:
|
|
940
|
+ f.write('test\n')
|
|
941
|
+
|
|
942
|
+ repo = create_repo('git', str(tmpdir))
|
|
943
|
+
|
|
944
|
+ top_commit = repo.create(repofiles)
|
|
945
|
+
|
|
946
|
+ repodir, reponame = os.path.split(repo.repo)
|
|
947
|
+ project_config = _yaml.load(os.path.join(project, 'project.conf'))
|
|
948
|
+ project_config['aliases'] = {
|
|
949
|
+ 'repo': 'http://example.com/'
|
|
950
|
+ }
|
|
951
|
+ project_config['mirrors'] = [
|
|
952
|
+ {
|
|
953
|
+ 'name': 'middle-earth',
|
|
954
|
+ 'aliases': {
|
|
955
|
+ 'repo': ['file://{}/'.format(repodir)]
|
|
956
|
+ }
|
|
957
|
+ }
|
|
958
|
+ ]
|
|
959
|
+ _yaml.dump(_yaml.node_sanitize(project_config), os.path.join(project, 'project.conf'))
|
|
960
|
+
|
|
961
|
+ repo.add_annotated_tag('tag', 'tag')
|
|
962
|
+
|
|
963
|
+ file1 = os.path.join(repofiles, 'file1')
|
|
964
|
+ with open(file1, 'w') as f:
|
|
965
|
+ f.write('test\n')
|
|
966
|
+
|
|
967
|
+ ref = repo.add_file(file1)
|
|
968
|
+
|
|
969
|
+ config = repo.source_config(ref=ref)
|
|
970
|
+ del config['track']
|
|
971
|
+ config['url'] = 'repo:{}'.format(reponame)
|
|
972
|
+
|
|
973
|
+ # Write out our test target
|
|
974
|
+ element = {
|
|
975
|
+ 'kind': 'import',
|
|
976
|
+ 'sources': [
|
|
977
|
+ config
|
|
978
|
+ ],
|
|
979
|
+ }
|
|
980
|
+ element_path = os.path.join(project, 'target.bst')
|
|
981
|
+ _yaml.dump(element, element_path)
|
|
982
|
+
|
|
983
|
+ result = cli.run(project=project, args=['build', 'target.bst'])
|
|
984
|
+ result.assert_success()
|
|
985
|
+
|
|
986
|
+ repo.checkout(top_commit)
|
|
987
|
+
|
|
988
|
+ file2 = os.path.join(repofiles, 'file2')
|
|
989
|
+ with open(file2, 'w') as f:
|
|
990
|
+ f.write('test\n')
|
|
991
|
+
|
|
992
|
+ new_ref = repo.add_file(file2)
|
|
993
|
+
|
|
994
|
+ repo.delete_tag('tag')
|
|
995
|
+ repo.add_annotated_tag('tag', 'tag')
|
|
996
|
+ repo.checkout('master')
|
|
997
|
+
|
|
998
|
+ otherpath = os.path.join(str(tmpdir), 'other_path')
|
|
999
|
+ shutil.copytree(repo.repo,
|
|
1000
|
+ os.path.join(otherpath, 'repo'))
|
|
1001
|
+ new_repo = create_repo('git', otherpath)
|
|
1002
|
+
|
|
1003
|
+ repodir, reponame = os.path.split(repo.repo)
|
|
1004
|
+
|
|
1005
|
+ _yaml.dump(_yaml.node_sanitize(project_config), os.path.join(project, 'project.conf'))
|
|
1006
|
+
|
|
1007
|
+ config = repo.source_config(ref=new_ref)
|
|
1008
|
+ del config['track']
|
|
1009
|
+ config['url'] = 'repo:{}'.format(reponame)
|
|
1010
|
+
|
|
1011
|
+ element = {
|
|
1012
|
+ 'kind': 'import',
|
|
1013
|
+ 'sources': [
|
|
1014
|
+ config
|
|
1015
|
+ ],
|
|
1016
|
+ }
|
|
1017
|
+ _yaml.dump(element, element_path)
|
|
1018
|
+
|
|
1019
|
+ result = cli.run(project=project, args=['build', 'target.bst'])
|
|
1020
|
+ result.assert_success()
|