@@ -5,9 +5,7 @@ use std::path::{Path, PathBuf};
5
5
use std:: process:: Command ;
6
6
7
7
use crate :: path:: { Dirs , RelPath } ;
8
- use crate :: utils:: {
9
- copy_dir_recursively, remove_dir_if_exists, retry_spawn_and_wait, spawn_and_wait,
10
- } ;
8
+ use crate :: utils:: { copy_dir_recursively, remove_dir_if_exists, spawn_and_wait} ;
11
9
12
10
pub ( crate ) fn prepare ( dirs : & Dirs ) {
13
11
RelPath :: DOWNLOAD . ensure_exists ( dirs) ;
@@ -110,7 +108,11 @@ impl GitRepo {
110
108
111
109
match self . url {
112
110
GitRepoUrl :: Github { user, repo } => {
113
- clone_repo_shallow_github ( dirs, & download_dir, user, repo, self . rev ) ;
111
+ clone_repo (
112
+ & download_dir,
113
+ & format ! ( "https://github.com/{}/{}.git" , user, repo) ,
114
+ self . rev ,
115
+ ) ;
114
116
}
115
117
}
116
118
@@ -145,7 +147,6 @@ impl GitRepo {
145
147
}
146
148
}
147
149
148
- #[ allow( dead_code) ]
149
150
fn clone_repo ( download_dir : & Path , repo : & str , rev : & str ) {
150
151
eprintln ! ( "[CLONE] {}" , repo) ;
151
152
// Ignore exit code as the repo may already have been checked out
@@ -162,55 +163,6 @@ fn clone_repo(download_dir: &Path, repo: &str, rev: &str) {
162
163
std:: fs:: remove_dir_all ( download_dir. join ( ".git" ) ) . unwrap ( ) ;
163
164
}
164
165
165
- fn clone_repo_shallow_github ( dirs : & Dirs , download_dir : & Path , user : & str , repo : & str , rev : & str ) {
166
- if cfg ! ( windows) {
167
- // Older windows doesn't have tar or curl by default. Fall back to using git.
168
- clone_repo ( download_dir, & format ! ( "https://github.com/{}/{}.git" , user, repo) , rev) ;
169
- return ;
170
- }
171
-
172
- let archive_url = format ! ( "https://github.com/{}/{}/archive/{}.tar.gz" , user, repo, rev) ;
173
- let archive_file = RelPath :: DOWNLOAD . to_path ( dirs) . join ( format ! ( "{}.tar.gz" , rev) ) ;
174
- let archive_dir = RelPath :: DOWNLOAD . to_path ( dirs) . join ( format ! ( "{}-{}" , repo, rev) ) ;
175
-
176
- eprintln ! ( "[DOWNLOAD] {}/{} from {}" , user, repo, archive_url) ;
177
-
178
- // Remove previous results if they exists
179
- let _ = std:: fs:: remove_file ( & archive_file) ;
180
- let _ = std:: fs:: remove_dir_all ( & archive_dir) ;
181
- let _ = std:: fs:: remove_dir_all ( & download_dir) ;
182
-
183
- // Download zip archive
184
- let mut download_cmd = Command :: new ( "curl" ) ;
185
- download_cmd
186
- . arg ( "--max-time" )
187
- . arg ( "600" )
188
- . arg ( "-y" )
189
- . arg ( "30" )
190
- . arg ( "-Y" )
191
- . arg ( "10" )
192
- . arg ( "--connect-timeout" )
193
- . arg ( "30" )
194
- . arg ( "--continue-at" )
195
- . arg ( "-" )
196
- . arg ( "--location" )
197
- . arg ( "--output" )
198
- . arg ( & archive_file)
199
- . arg ( archive_url) ;
200
- retry_spawn_and_wait ( 5 , download_cmd) ;
201
-
202
- // Unpack tar archive
203
- let mut unpack_cmd = Command :: new ( "tar" ) ;
204
- unpack_cmd. arg ( "xf" ) . arg ( & archive_file) . current_dir ( RelPath :: DOWNLOAD . to_path ( dirs) ) ;
205
- spawn_and_wait ( unpack_cmd) ;
206
-
207
- // Rename unpacked dir to the expected name
208
- std:: fs:: rename ( archive_dir, & download_dir) . unwrap ( ) ;
209
-
210
- // Cleanup
211
- std:: fs:: remove_file ( archive_file) . unwrap ( ) ;
212
- }
213
-
214
166
fn init_git_repo ( repo_dir : & Path ) {
215
167
let mut git_init_cmd = git_command ( repo_dir, "init" ) ;
216
168
git_init_cmd. arg ( "-q" ) ;
0 commit comments