@@ -2491,16 +2491,22 @@ def test_get_source_tarball_from_git(self):
24912491 git_config = {
24922492 'repo_name' : 'testrepository' ,
24932493 'url' : 'https://github.com/easybuilders' ,
2494- 'tag' : 'main ' ,
2494+ 'tag' : 'tag_for_tests ' ,
24952495 }
24962496 target_dir = os .path .join (self .test_prefix , 'target' )
24972497
24982498 try :
24992499 ft .get_source_tarball_from_git ('test.tar.gz' , target_dir , git_config )
25002500 # (only) tarball is created in specified target dir
2501- self .assertTrue (os .path .isfile (os .path .join (target_dir , 'test.tar.gz' )))
2501+ test_file = os .path .join (target_dir , 'test.tar.gz' )
2502+ self .assertTrue (os .path .isfile (test_file ))
25022503 self .assertEqual (os .listdir (target_dir ), ['test.tar.gz' ])
25032504
2505+ # Check that we indeed downloaded the tag and not a branch
2506+ extracted_dir = tempfile .mkdtemp (prefix = 'extracted_dir' )
2507+ target_dir = ft .extract_file (test_file , extracted_dir , change_into_dir = False )
2508+ self .assertTrue (os .path .isfile (os .path .join (target_dir , 'this-is-a-tag.txt' )))
2509+
25042510 del git_config ['tag' ]
25052511 git_config ['commit' ] = '8456f86'
25062512 ft .get_source_tarball_from_git ('test2.tar.gz' , target_dir , git_config )
@@ -2516,7 +2522,7 @@ def test_get_source_tarball_from_git(self):
25162522 git_config = {
25172523 'repo_name' : 'testrepository' ,
25182524 'url' :
'[email protected] :easybuilders' ,
2519- 'tag' : 'master ' ,
2525+ 'tag' : 'tag_for_tests ' ,
25202526 }
25212527 args = ['test.tar.gz' , self .test_prefix , git_config ]
25222528
@@ -2570,10 +2576,10 @@ def run_check():
25702576 git_config = {
25712577 'repo_name' : 'testrepository' ,
25722578 'url' :
'[email protected] :easybuilders' ,
2573- 'tag' : 'master ' ,
2579+ 'tag' : 'tag_for_tests ' ,
25742580 }
25752581 expected = '\n ' .join ([
2576- r' running command "git clone --branch master [email protected] :easybuilders/testrepository.git"' ,
2582+ r' running command "git clone --branch refs/tags/tag_for_tests [email protected] :easybuilders/testrepository.git"' ,
25772583 r" \(in .*/tmp.*\)" ,
25782584 r' running command "tar cfvz .*/target/test.tar.gz --exclude .git testrepository"' ,
25792585 r" \(in .*/tmp.*\)" ,
@@ -2582,7 +2588,7 @@ def run_check():
25822588
25832589 git_config ['recursive' ] = True
25842590 expected = '\n ' .join ([
2585- r' running command "git clone --branch master --recursive [email protected] :easybuilders/testrepository.git"' ,
2591+ r' running command "git clone --branch refs/tags/tag_for_tests --recursive [email protected] :easybuilders/testrepository.git"' ,
25862592 r" \(in .*/tmp.*\)" ,
25872593 r' running command "tar cfvz .*/target/test.tar.gz --exclude .git testrepository"' ,
25882594 r" \(in .*/tmp.*\)" ,
@@ -2591,7 +2597,7 @@ def run_check():
25912597
25922598 git_config ['keep_git_dir' ] = True
25932599 expected = '\n ' .join ([
2594- r' running command "git clone --branch master --recursive [email protected] :easybuilders/testrepository.git"' ,
2600+ r' running command "git clone --branch refs/tags/tag_for_tests --recursive [email protected] :easybuilders/testrepository.git"' ,
25952601 r" \(in .*/tmp.*\)" ,
25962602 r' running command "tar cfvz .*/target/test.tar.gz testrepository"' ,
25972603 r" \(in .*/tmp.*\)" ,
0 commit comments