@@ -6,6 +6,7 @@ use std::{
6
6
path:: { Path , PathBuf } ,
7
7
process:: { Command , Stdio } ,
8
8
sync:: OnceLock ,
9
+ time:: SystemTime ,
9
10
} ;
10
11
11
12
use build_helper:: ci:: CiEnv ;
@@ -250,19 +251,74 @@ impl Config {
250
251
"(New-Object System.Net.WebClient).DownloadFile('{}', '{}')" ,
251
252
url, tempfile. to_str( ) . expect( "invalid UTF-8 not supported with powershell downloads" ) ,
252
253
) ,
253
- ] ) ) . is_err ( ) {
254
+ ] ) ) . is_ok ( ) {
254
255
return ;
255
256
}
256
257
eprintln ! ( "\n spurious failure, trying again" ) ;
257
258
}
258
259
}
259
260
if !help_on_error. is_empty ( ) {
260
261
eprintln ! ( "{help_on_error}" ) ;
262
+ if Self :: check_outdated ( ) {
263
+ eprintln ! ( "NOTE: you seem to have an outdated version of rust source" ) ;
264
+ }
261
265
}
262
266
crate :: exit!( 1 ) ;
263
267
}
264
268
}
265
269
270
+ fn check_outdated ( ) -> bool {
271
+ let user: String = Command :: new ( "git" )
272
+ . arg ( "config" )
273
+ . arg ( "user.name" )
274
+ . output ( )
275
+ . expect ( "Failed to get git user.name" )
276
+ . stdout
277
+ . into_iter ( )
278
+ . map ( |c| c as char )
279
+ . collect ( ) ;
280
+ let log: String = Command :: new ( "git" )
281
+ . arg ( "log" )
282
+ . arg ( "--pretty=short" )
283
+ . arg ( "origin/master..HEAD" )
284
+ . output ( )
285
+ . expect ( "Failed to get git log" )
286
+ . stdout
287
+ . into_iter ( )
288
+ . map ( |c| c as char )
289
+ . collect ( ) ;
290
+ for s in log. split ( "\n " ) {
291
+ if s. contains ( "Author:" ) {
292
+ if !s. contains ( & format ! ( "Author: {}" , user. replace( "\n " , "" ) ) ) {
293
+ return true ;
294
+ }
295
+ }
296
+ }
297
+ let last_commit: String = Command :: new ( "git" )
298
+ . arg ( "show" )
299
+ . arg ( "-s" )
300
+ . arg ( "--date=short" )
301
+ . arg ( "--format=%ct" )
302
+ . arg ( "origin/master" )
303
+ . output ( )
304
+ . expect ( "Failed to get git log" )
305
+ . stdout
306
+ . into_iter ( )
307
+ . map ( |c| c as char )
308
+ . collect ( ) ;
309
+ match SystemTime :: now ( ) . duration_since ( SystemTime :: UNIX_EPOCH ) {
310
+ Ok ( n) => {
311
+ let replaced = last_commit. replace ( "\n " , "" ) ;
312
+ if n. as_secs ( ) - replaced. parse :: < u64 > ( ) . unwrap ( ) >= 10 * 24 * 60 * 60 {
313
+ // HEAD is more than 10 days out of date
314
+ return true ;
315
+ }
316
+ }
317
+ Err ( _) => panic ! ( "SystemTime before UNIX EPOCH!" ) ,
318
+ }
319
+ return false ;
320
+ }
321
+
266
322
fn unpack ( & self , tarball : & Path , dst : & Path , pattern : & str ) {
267
323
eprintln ! ( "extracting {} to {}" , tarball. display( ) , dst. display( ) ) ;
268
324
if !dst. exists ( ) {
0 commit comments