Skip to content

Commit d5fe74b

Browse files
committed
Extract get_start_date and get_end_date logic to functions
1 parent cc640f6 commit d5fe74b

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

src/main.rs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,26 @@ fn bisect_to_regression(
843843
Ok(found)
844844
}
845845

846+
fn get_start_date(cfg: &Config) -> chrono::Date<Utc> {
847+
if let Some(Bound::Date(date)) = cfg.args.start {
848+
date
849+
} else {
850+
get_end_date(cfg)
851+
}
852+
}
853+
854+
fn get_end_date(cfg: &Config) -> chrono::Date<Utc> {
855+
if let Some(Bound::Date(date)) = cfg.args.end {
856+
date
857+
} else {
858+
if let Some(date) = Toolchain::default_nightly() {
859+
date
860+
} else {
861+
chrono::Utc::now().date()
862+
}
863+
}
864+
}
865+
846866
// nightlies branch of bisect execution
847867
fn bisect_nightlies(cfg: &Config, client: &Client) -> Result<BisectionResult, Error> {
848868
if cfg.args.alt {
@@ -858,21 +878,9 @@ fn bisect_nightlies(cfg: &Config, client: &Client) -> Result<BisectionResult, Er
858878
);
859879
let mut first_success = None;
860880

861-
let mut last_failure = if let Some(Bound::Date(date)) = cfg.args.end {
862-
date
863-
} else {
864-
if let Some(date) = Toolchain::default_nightly() {
865-
date
866-
} else {
867-
chrono::Utc::now().date()
868-
}
869-
};
870-
871-
let (mut nightly_date, has_start) = if let Some(Bound::Date(date)) = cfg.args.start {
872-
(date, true)
873-
} else {
874-
(last_failure, false)
875-
};
881+
let mut nightly_date = get_start_date(cfg);
882+
let mut last_failure = get_end_date(cfg);
883+
let has_start = cfg.args.start.is_some();
876884

877885
let mut nightly_iter = NightlyFinderIter::new(nightly_date);
878886

0 commit comments

Comments
 (0)