Skip to content

Commit 50e8e29

Browse files
authored
Merge pull request #115 from lzutao/shorter-date
Use shorter method to calculate successor or previous date
2 parents b62e456 + 48e297d commit 50e8e29

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::path::PathBuf;
77
use std::process::{self, Command};
88
use std::str::FromStr;
99

10-
use chrono::{Date, DateTime, Duration, Utc};
10+
use chrono::{Date, DateTime, Utc};
1111
use colored::*;
1212
use failure::{bail, format_err, Fail, Error};
1313
use log::debug;
@@ -591,7 +591,7 @@ fn bisect(cfg: &Config, client: &Client) -> Result<(), Error> {
591591
let nightly_regression = &nightly_bisection_result.searched[nightly_bisection_result.found];
592592

593593
if let ToolchainSpec::Nightly { date } = nightly_regression.spec {
594-
let previous_date = date - chrono::Duration::days(1);
594+
let previous_date = date.pred();
595595

596596
let working_commit = Bound::Date(previous_date).sha()?;
597597
let bad_commit = Bound::Date(date).sha()?;
@@ -998,7 +998,7 @@ fn bisect_nightlies(cfg: &Config, client: &Client) -> Result<BisectionResult, Er
998998
}
999999
Err(InstallError::NotFound { .. }) => {
10001000
// go back just one day, presumably missing a nightly
1001-
nightly_date = nightly_date - chrono::Duration::days(1);
1001+
nightly_date = nightly_date.pred();
10021002
eprintln!(
10031003
"*** unable to install {}. roll back one day and try again...",
10041004
t
@@ -1067,7 +1067,7 @@ fn toolchains_between(cfg: &Config, a: ToolchainSpec, b: ToolchainSpec) -> Vec<T
10671067
t.std_targets.sort();
10681068
t.std_targets.dedup();
10691069
toolchains.push(t);
1070-
date = date + Duration::days(1);
1070+
date = date.succ();
10711071
}
10721072
toolchains
10731073
}

src/repo_access.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ impl RustRepositoryAccessor for AccessViaGithub {
6767
// Because: the "since" parameter in the github API is an exclusive
6868
// bound. We need an inclusive bound, so we go yet another day prior for
6969
// this bound on the github search.
70-
let since_date =
71-
self.bound_to_date(Bound::Commit(start_sha.to_string()))? - chrono::Duration::days(1);
70+
let since_date = self
71+
.bound_to_date(Bound::Commit(start_sha.to_string()))?
72+
.pred();
7273

7374
eprintln!(
7475
"fetching (via remote github) commits from max({}, {}) to {}",

0 commit comments

Comments
 (0)