@@ -6,6 +6,7 @@ use std::{
66 path:: { Path , PathBuf } ,
77 process:: { Command , Stdio } ,
88 sync:: OnceLock ,
9+ time:: SystemTime ,
910} ;
1011
1112use build_helper:: ci:: CiEnv ;
@@ -250,19 +251,74 @@ impl Config {
250251 "(New-Object System.Net.WebClient).DownloadFile('{}', '{}')" ,
251252 url, tempfile. to_str( ) . expect( "invalid UTF-8 not supported with powershell downloads" ) ,
252253 ) ,
253- ] ) ) . is_err ( ) {
254+ ] ) ) . is_ok ( ) {
254255 return ;
255256 }
256257 eprintln ! ( "\n spurious failure, trying again" ) ;
257258 }
258259 }
259260 if !help_on_error. is_empty ( ) {
260261 eprintln ! ( "{help_on_error}" ) ;
262+ if Self :: check_outdated ( ) {
263+ eprintln ! ( "NOTE: you seem to have an outdated version of rust source" ) ;
264+ }
261265 }
262266 crate :: exit!( 1 ) ;
263267 }
264268 }
265269
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+
266322 fn unpack ( & self , tarball : & Path , dst : & Path , pattern : & str ) {
267323 eprintln ! ( "extracting {} to {}" , tarball. display( ) , dst. display( ) ) ;
268324 if !dst. exists ( ) {
0 commit comments