@@ -484,6 +484,42 @@ impl Config {
484
484
}
485
485
}
486
486
487
+ /// Translates a tag-like bound (such as `1.62.0`) to a `Bound::Date` so that
488
+ /// bisecting works for versions older than 167 days.
489
+ fn fixup_bounds (
490
+ access : & Access ,
491
+ start : & mut Option < Bound > ,
492
+ end : & mut Option < Bound > ,
493
+ ) -> anyhow:: Result < ( ) > {
494
+ let is_tag = |bound : & Option < Bound > | -> bool {
495
+ match bound {
496
+ Some ( Bound :: Commit ( commit) ) => commit. contains ( '.' ) ,
497
+ None | Some ( Bound :: Date ( _) ) => false ,
498
+ }
499
+ } ;
500
+ let is_datelike = |bound : & Option < Bound > | -> bool {
501
+ matches ! ( bound, None | Some ( Bound :: Date ( _) ) ) || is_tag ( bound)
502
+ } ;
503
+ if !( is_datelike ( start) && is_datelike ( end) ) {
504
+ // If the user specified an actual commit for one bound, then don't
505
+ // even try to convert the other bound to a date.
506
+ return Ok ( ( ) ) ;
507
+ }
508
+ let fixup = |bound : & mut Option < Bound > | -> anyhow:: Result < ( ) > {
509
+ if is_tag ( bound) {
510
+ if let Some ( b) = bound. clone ( ) {
511
+ if is_tag ( bound) {
512
+ * bound = Some ( Bound :: Date ( access. repo ( ) . bound_to_date ( b) ?) ) ;
513
+ }
514
+ }
515
+ }
516
+ Ok ( ( ) )
517
+ } ;
518
+ fixup ( start) ?;
519
+ fixup ( end) ?;
520
+ Ok ( ( ) )
521
+ }
522
+
487
523
fn check_bounds ( start : & Option < Bound > , end : & Option < Bound > ) -> anyhow:: Result < ( ) > {
488
524
// current UTC date
489
525
let current = Utc :: today ( ) ;
@@ -519,7 +555,8 @@ fn check_bounds(start: &Option<Bound>, end: &Option<Bound>) -> anyhow::Result<()
519
555
// Application entry point
520
556
fn run ( ) -> anyhow:: Result < ( ) > {
521
557
env_logger:: try_init ( ) ?;
522
- let args = Opts :: parse ( ) ;
558
+ let mut args = Opts :: parse ( ) ;
559
+ fixup_bounds ( & args. access , & mut args. start , & mut args. end ) ?;
523
560
check_bounds ( & args. start , & args. end ) ?;
524
561
let cfg = Config :: from_args ( args) ?;
525
562
0 commit comments