Skip to content

Commit 591db74

Browse files
committed
Replace humantime dependency for jiff
1 parent fbcd538 commit 591db74

File tree

4 files changed

+66
-33
lines changed

4 files changed

+66
-33
lines changed

Cargo.lock

+48-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/trycmd/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ rayon = "1.5.1"
5555

5656
serde = { version = "1.0", features = ["derive"] }
5757
shlex = "1.1.0"
58-
humantime = "2"
59-
humantime-serde = "1"
58+
jiff = { version = "0.2.4", default-features = false }
6059
toml_edit = { version = "0.22.13", features = ["serde"] }
6160
escargot = { version = "0.5.13", optional = true }
6261

crates/trycmd/src/runner.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::eprintln;
1111
#[cfg(not(feature = "color"))]
1212
use std::io::stderr;
1313

14+
use jiff::SignedDuration;
1415
use rayon::prelude::*;
1516
use snapbox::data::DataFormat;
1617
use snapbox::dir::FileType;
@@ -68,10 +69,11 @@ impl Runner {
6869
status.spawn.status.summary(),
6970
);
7071
if let Some(duration) = status.duration {
72+
let duration = SignedDuration::try_from(duration).unwrap();
7173
let _ = write!(
7274
stderr,
7375
" {}",
74-
palette.hint(humantime::format_duration(duration)),
76+
palette.hint(format!("{duration:#}")),
7577
);
7678
}
7779
let _ = writeln!(stderr);
@@ -90,10 +92,11 @@ impl Runner {
9092
palette.error("failed"),
9193
);
9294
if let Some(duration) = status.duration {
95+
let duration = SignedDuration::try_from(duration).unwrap();
9396
let _ = write!(
9497
stderr,
9598
" {}",
96-
palette.hint(humantime::format_duration(duration)),
99+
palette.hint(format!("{duration:#}")),
97100
);
98101
}
99102
let _ = writeln!(stderr);

crates/trycmd/src/schema.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -645,12 +645,23 @@ pub struct OneShot {
645645
#[serde(default)]
646646
pub(crate) binary: bool,
647647
#[serde(default)]
648-
#[serde(deserialize_with = "humantime_serde::deserialize")]
648+
#[serde(deserialize_with = "deserialize_jiff_duration")]
649649
pub(crate) timeout: Option<std::time::Duration>,
650650
#[serde(default)]
651651
pub(crate) fs: Filesystem,
652652
}
653653

654+
fn deserialize_jiff_duration<'de, D>(deserializer: D) -> Result<Option<std::time::Duration>, D::Error>
655+
where D: serde::Deserializer<'de> {
656+
use serde::de::Deserialize;
657+
658+
let buf = String::deserialize(deserializer)?;
659+
660+
buf
661+
.parse::<jiff::SignedDuration>()
662+
.map(|e| Some(e.unsigned_abs())).map_err(serde::de::Error::custom)
663+
}
664+
654665
impl OneShot {
655666
fn parse_toml(s: &str) -> Result<Self, crate::Error> {
656667
toml_edit::de::from_str(s).map_err(|e| e.to_string().into())

0 commit comments

Comments
 (0)