@@ -3073,16 +3073,31 @@ def run_check():
3073
3073
del git_config ['extra_config_params' ]
3074
3074
3075
3075
del git_config ['tag' ]
3076
+ git_config ['commit' ] = '90366eac4408c5d615d69c5444ed784734b167c8'
3077
+ string_args ['commit' ] = git_config ['commit' ]
3078
+ expected = '\n ' .join ([
3079
+ r' running command "git clone --no-checkout %(git_repo)s"' ,
3080
+ r" \(in .*/tmp.*\)" ,
3081
+ r' running command "git fetch %(git_repo)s %(commit)s"' ,
3082
+ r" \(in testrepository\)" ,
3083
+ r' running command "git checkout %(commit)s && git submodule update --init --recursive"' ,
3084
+ r" \(in testrepository\)" ,
3085
+ r' running command "tar cfvz .*/target/test.tar.gz --exclude .git testrepository"' ,
3086
+ r" \(in .*/tmp.*\)" ,
3087
+ ]) % string_args
3088
+ run_check ()
3089
+
3090
+ # clone & fetch does not work for short hashes
3076
3091
git_config ['commit' ] = '8456f86'
3092
+ string_args ['commit' ] = git_config ['commit' ]
3077
3093
expected = '\n ' .join ([
3078
3094
r' running shell command "git clone --no-checkout {git_repo}"' ,
3079
3095
r" \(in .*/tmp.*\)" ,
3080
- r' running shell command "git checkout 8456f86"' ,
3081
- r" \(in .*/{repo_name}\)" ,
3082
- r' running shell command "git submodule update --init --recursive"' ,
3083
- r" \(in .*/{repo_name}\)" ,
3084
- r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'..." ,
3085
- ]).format (** string_args , repo_name = 'testrepository' )
3096
+ r' running command "git checkout %(commit)s && git submodule update --init --recursive"' ,
3097
+ r" \(in testrepository\)" ,
3098
+ r' running command "tar cfvz .*/target/test.tar.gz --exclude .git testrepository"' ,
3099
+ r" \(in .*/tmp.*\)" ,
3100
+ ]) % string_args
3086
3101
run_check ()
3087
3102
3088
3103
git_config ['recurse_submodules' ] = ['!vcflib' , '!sdsl-lite' ]
@@ -3170,18 +3185,15 @@ def run_check():
3170
3185
self .assertFalse (os .path .isdir (os .path .join (extracted_repo_dir , '.git' )))
3171
3186
3172
3187
del git_config ['tag' ]
3173
- git_config ['commit' ] = '90366ea'
3174
- res = ft .get_source_tarball_from_git ('test2' , target_dir , git_config )
3175
- test_file = os .path .join (target_dir , 'test2.tar.xz' )
3176
- self .assertEqual (res , test_file )
3177
- self .assertTrue (os .path .isfile (test_file ))
3178
- test_tar_files .append (os .path .basename (test_file ))
3179
- self .assertCountEqual (sorted (os .listdir (target_dir )), test_tar_files )
3180
- extracted_dir = tempfile .mkdtemp (prefix = 'extracted_dir' )
3181
- with self .mocked_stdout_stderr ():
3182
- extracted_repo_dir = ft .extract_file (test_file , extracted_dir , change_into_dir = False )
3183
- self .assertTrue (os .path .isfile (os .path .join (extracted_repo_dir , 'README.md' )))
3184
- self .assertFalse (os .path .isdir (os .path .join (extracted_repo_dir , '.git' )))
3188
+ test_tar_gzs = []
3189
+ for i , commit in enumerate (['90366eac4408c5d615d69c5444ed784734b167c8' , '90366ea' ]):
3190
+ git_config ['commit' ] = commit
3191
+ test_file = os .path .join (target_dir , 'test2-%s.tar.gz' % i )
3192
+ res = ft .get_source_tarball_from_git (os .path .basename (test_file ), target_dir , git_config )
3193
+ self .assertEqual (res , test_file )
3194
+ self .assertTrue (os .path .isfile (test_file ))
3195
+ test_tar_gzs .append (os .path .basename (test_file ))
3196
+ self .assertEqual (sorted (os .listdir (target_dir )), test_tar_gzs )
3185
3197
3186
3198
git_config ['keep_git_dir' ] = True
3187
3199
res = ft .get_source_tarball_from_git ('test3' , target_dir , git_config )
0 commit comments