File tree 1 file changed +26
-1
lines changed
1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -464,9 +464,16 @@ impl ToolchainDesc {
464
464
}
465
465
}
466
466
467
+ /// Toolchain channels are considered 'tracking' if it is one of the named channels
468
+ /// such as `stable`, or is an incomplete version such as `1.48`, and the
469
+ /// date field is empty.
467
470
pub fn is_tracking ( & self ) -> bool {
468
471
let channels = [ "nightly" , "beta" , "stable" ] ;
469
- channels. iter ( ) . any ( |x| * x == self . channel ) && self . date . is_none ( )
472
+ lazy_static ! {
473
+ static ref TRACKING_VERSION : Regex = Regex :: new( r"^\d{1}\.\d{1,3}$" ) . unwrap( ) ;
474
+ }
475
+ ( channels. iter ( ) . any ( |x| * x == self . channel ) || TRACKING_VERSION . is_match ( & self . channel ) )
476
+ && self . date . is_none ( )
470
477
}
471
478
}
472
479
@@ -1079,4 +1086,22 @@ mod tests {
1079
1086
) ;
1080
1087
}
1081
1088
}
1089
+
1090
+ #[ test]
1091
+ fn test_tracking_channels ( ) {
1092
+ static CASES : & [ ( & str , bool ) ] = & [
1093
+ ( "stable" , true ) ,
1094
+ ( "beta" , true ) ,
1095
+ ( "nightly" , true ) ,
1096
+ ( "nightly-2020-10-04" , false ) ,
1097
+ ( "1.48" , true ) ,
1098
+ ( "1.47.0" , false ) ,
1099
+ ] ;
1100
+ for case in CASES {
1101
+ let full_tcn = format ! ( "{}-x86_64-unknown-linux-gnu" , case. 0 ) ;
1102
+ let tcd = ToolchainDesc :: from_str ( & full_tcn) . unwrap ( ) ;
1103
+ eprintln ! ( "Considering {}" , case. 0 ) ;
1104
+ assert_eq ! ( tcd. is_tracking( ) , case. 1 ) ;
1105
+ }
1106
+ }
1082
1107
}
You can’t perform that action at this time.
0 commit comments