From 42a22c12f1ad54e85f11c4fc4f17af786589e39a Mon Sep 17 00:00:00 2001 From: Wandering Lethe Date: Mon, 5 Jun 2023 21:41:32 +0200 Subject: [PATCH 1/4] Remove time dependency from date Also upgrades humantime_to_duration to the latest version, it switched from time to chrono. Because touch still depends on time, its humantime_to_duration package version deviates from the workspace version. --- Cargo.lock | 47 +++++++++++++++++++++++++++++++++-------- Cargo.toml | 2 +- src/uu/date/Cargo.toml | 2 -- src/uu/date/src/date.rs | 12 ++++------- src/uu/touch/Cargo.toml | 3 ++- 5 files changed, 45 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7c826fac5..63d748f9d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -272,7 +272,10 @@ checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" dependencies = [ "android-tzdata", "iana-time-zone", + "js-sys", "num-traits", + "time 0.1.45", + "wasm-bindgen", "winapi", ] @@ -421,7 +424,7 @@ dependencies = [ "sha1", "tempfile", "textwrap", - "time", + "time 0.3.20", "unindent", "uu_arch", "uu_base32", @@ -1079,7 +1082,7 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] @@ -1151,7 +1154,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "714764645f21cc70c4c151d7798dd158409641f37ad820bed65224aae403cbed" dependencies = [ "regex", - "time", + "time 0.3.20", +] + +[[package]] +name = "humantime_to_duration" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a674b970a2bbad01671718ca07604ca89258dd5e25d9af835c14ac6e0bc792" +dependencies = [ + "chrono", + "regex", ] [[package]] @@ -1434,7 +1447,7 @@ checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.45.0", ] @@ -2289,6 +2302,17 @@ dependencies = [ "syn", ] +[[package]] +name = "time" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi", +] + [[package]] name = "time" version = "0.3.20" @@ -2528,9 +2552,8 @@ version = "0.0.19" dependencies = [ "chrono", "clap", - "humantime_to_duration", + "humantime_to_duration 0.3.0", "libc", - "time", "uucore", "windows-sys 0.48.0", ] @@ -3224,8 +3247,8 @@ version = "0.0.19" dependencies = [ "clap", "filetime", - "humantime_to_duration", - "time", + "humantime_to_duration 0.2.1", + "time 0.3.20", "uucore", "windows-sys 0.48.0", ] @@ -3401,7 +3424,7 @@ dependencies = [ "sm3", "tempfile", "thiserror", - "time", + "time 0.3.20", "uucore_procs", "walkdir", "wild", @@ -3446,6 +3469,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index d939d43f7..3df9aa1ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -286,7 +286,7 @@ fundu = "0.5.1" gcd = "2.3" glob = "0.3.1" half = "2.2" -humantime_to_duration = "0.2.1" +humantime_to_duration = "0.3.0" indicatif = "0.17" is-terminal = "0.4.7" itertools = "0.10.5" diff --git a/src/uu/date/Cargo.toml b/src/uu/date/Cargo.toml index 852e8cc9d..1ffcbed66 100644 --- a/src/uu/date/Cargo.toml +++ b/src/uu/date/Cargo.toml @@ -17,8 +17,6 @@ path = "src/date.rs" [dependencies] chrono = { workspace=true } -#/ TODO: check if we can avoid chrono+time -time = { workspace=true } clap = { workspace=true } uucore = { workspace=true } humantime_to_duration = { workspace=true } diff --git a/src/uu/date/src/date.rs b/src/uu/date/src/date.rs index 381619f06..44b54be5e 100644 --- a/src/uu/date/src/date.rs +++ b/src/uu/date/src/date.rs @@ -9,7 +9,7 @@ // spell-checker:ignore (chrono) Datelike Timelike ; (format) DATEFILE MMDDhhmm ; (vars) datetime datetimes humantime use chrono::format::{Item, StrftimeItems}; -use chrono::{DateTime, Duration as ChronoDuration, FixedOffset, Local, Offset, Utc}; +use chrono::{DateTime, Duration, FixedOffset, Local, Offset, Utc}; #[cfg(windows)] use chrono::{Datelike, Timelike}; use clap::{crate_version, Arg, ArgAction, Command}; @@ -18,7 +18,6 @@ use libc::{clock_settime, timespec, CLOCK_REALTIME}; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::PathBuf; -use time::Duration; use uucore::display::Quotable; #[cfg(not(any(target_os = "redox")))] use uucore::error::FromIo; @@ -226,13 +225,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let iter = std::iter::once(date); Box::new(iter) } - DateSource::Human(ref input) => { - // Get the current DateTime and convert the input time::Duration to chrono::Duration - // for things like "1 year ago" + DateSource::Human(relative_time) => { + // Get the current DateTime for things like "1 year ago" let current_time = DateTime::::from(Local::now()); - let input_chrono = ChronoDuration::seconds(input.as_seconds_f32() as i64) - + ChronoDuration::nanoseconds(input.subsec_nanoseconds() as i64); - let iter = std::iter::once(Ok(current_time + input_chrono)); + let iter = std::iter::once(Ok(current_time + relative_time)); Box::new(iter) } DateSource::File(ref path) => { diff --git a/src/uu/touch/Cargo.toml b/src/uu/touch/Cargo.toml index 3aac9abc4..80840525c 100644 --- a/src/uu/touch/Cargo.toml +++ b/src/uu/touch/Cargo.toml @@ -18,7 +18,8 @@ path = "src/touch.rs" [dependencies] filetime = { workspace=true } clap = { workspace=true } -humantime_to_duration = { workspace=true } +# TODO: use workspace dependency (0.3) when switching from time to chrono +humantime_to_duration = "0.2.1" time = { workspace=true, features = ["parsing", "formatting", "local-offset", "macros"] } uucore = { workspace=true, features=["libc"] } From 2842d1fa0f2d0004d84805b73a413e31686bceb3 Mon Sep 17 00:00:00 2001 From: Wandering Lethe Date: Mon, 5 Jun 2023 22:54:26 +0200 Subject: [PATCH 2/4] Add duplicate packages to deny ban skips Duplicates of humantime_to_duration and time can be removed when touch switches from time to chrono --- deny.toml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/deny.toml b/deny.toml index 14470b9b0..aa0203b9b 100644 --- a/deny.toml +++ b/deny.toml @@ -76,8 +76,11 @@ skip = [ { name = "windows_x86_64_msvc", version = "0.42.2" }, # tempfile { name = "redox_syscall", version = "0.3.5" }, - # cpp_macros - { name = "aho-corasick", version = "0.7.19" }, + # chrono -> time + { name = "wasi", version = "0.10.0+wasi-snapshot-preview1" }, + # touch can be remove when touch switches from time to chrono + { name = "humantime_to_duration", version = "0.2.1" }, + { name = "time", version = "0.3.20" }, ] # spell-checker: enable From 1ff4684f8a757ea570642d7a97f9486d8303f174 Mon Sep 17 00:00:00 2001 From: Wandering Lethe Date: Mon, 5 Jun 2023 23:01:26 +0200 Subject: [PATCH 3/4] Revert accidental removal of skipped deny --- deny.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deny.toml b/deny.toml index aa0203b9b..ba516de84 100644 --- a/deny.toml +++ b/deny.toml @@ -76,6 +76,8 @@ skip = [ { name = "windows_x86_64_msvc", version = "0.42.2" }, # tempfile { name = "redox_syscall", version = "0.3.5" }, + # cpp_macros + { name = "aho-corasick", version = "0.7.19" }, # chrono -> time { name = "wasi", version = "0.10.0+wasi-snapshot-preview1" }, # touch can be remove when touch switches from time to chrono From 81313e63eab50a38ffa7c8d5bdcd769aac31ee3f Mon Sep 17 00:00:00 2001 From: Wandering Lethe Date: Tue, 6 Jun 2023 18:07:21 +0200 Subject: [PATCH 4/4] Upgrade humantime_to_duration to version 0.3.1. Latest patch fixes the transitive dependency on time. Which can now also be removed from the deny skipped bans. --- Cargo.lock | 38 +++++++++----------------------------- Cargo.toml | 2 +- deny.toml | 5 +---- 3 files changed, 11 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 63d748f9d..1603bdc56 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -272,10 +272,7 @@ checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" dependencies = [ "android-tzdata", "iana-time-zone", - "js-sys", "num-traits", - "time 0.1.45", - "wasm-bindgen", "winapi", ] @@ -424,7 +421,7 @@ dependencies = [ "sha1", "tempfile", "textwrap", - "time 0.3.20", + "time", "unindent", "uu_arch", "uu_base32", @@ -1082,7 +1079,7 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -1154,14 +1151,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "714764645f21cc70c4c151d7798dd158409641f37ad820bed65224aae403cbed" dependencies = [ "regex", - "time 0.3.20", + "time", ] [[package]] name = "humantime_to_duration" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a674b970a2bbad01671718ca07604ca89258dd5e25d9af835c14ac6e0bc792" +checksum = "1a80a233096ddccb74e62145f3a49cacea6a2669ee90f6e144e15fe28f4037c4" dependencies = [ "chrono", "regex", @@ -1447,7 +1444,7 @@ checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.45.0", ] @@ -2302,17 +2299,6 @@ dependencies = [ "syn", ] -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - [[package]] name = "time" version = "0.3.20" @@ -2552,7 +2538,7 @@ version = "0.0.19" dependencies = [ "chrono", "clap", - "humantime_to_duration 0.3.0", + "humantime_to_duration 0.3.1", "libc", "uucore", "windows-sys 0.48.0", @@ -3248,7 +3234,7 @@ dependencies = [ "clap", "filetime", "humantime_to_duration 0.2.1", - "time 0.3.20", + "time", "uucore", "windows-sys 0.48.0", ] @@ -3424,7 +3410,7 @@ dependencies = [ "sm3", "tempfile", "thiserror", - "time 0.3.20", + "time", "uucore_procs", "walkdir", "wild", @@ -3469,12 +3455,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 3df9aa1ac..9c8d769a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -286,7 +286,7 @@ fundu = "0.5.1" gcd = "2.3" glob = "0.3.1" half = "2.2" -humantime_to_duration = "0.3.0" +humantime_to_duration = "0.3.1" indicatif = "0.17" is-terminal = "0.4.7" itertools = "0.10.5" diff --git a/deny.toml b/deny.toml index ba516de84..c84984230 100644 --- a/deny.toml +++ b/deny.toml @@ -78,11 +78,8 @@ skip = [ { name = "redox_syscall", version = "0.3.5" }, # cpp_macros { name = "aho-corasick", version = "0.7.19" }, - # chrono -> time - { name = "wasi", version = "0.10.0+wasi-snapshot-preview1" }, - # touch can be remove when touch switches from time to chrono + # touch, can be remove when touch switches from time to chrono { name = "humantime_to_duration", version = "0.2.1" }, - { name = "time", version = "0.3.20" }, ] # spell-checker: enable