From 53b0a6406e0a66435b99ff62348acd5b738c29c2 Mon Sep 17 00:00:00 2001 From: Remo Senekowitsch Date: Tue, 30 Jul 2024 11:12:33 +0200 Subject: [PATCH 1/4] Sort dependencies alphabetically --- Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 69e223a..ba3a5d0 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,18 +13,18 @@ A Cargo subcommand for managing local registries. edition = "2021" [dependencies] +anyhow = "1.0.47" cargo = "0.81.0" +cargo-platform = "0.1.0" docopt = "1.1.0" env_logger = "0.7.0" failure = "0.1.8" flate2 = "1.0.22" +openssl = { version = '0.10.41', optional = true } serde = { version = "1.0.104", features = ['derive'] } serde_json = "1.0.46" tar = "0.4.26" -openssl = { version = '0.10.41', optional = true } -cargo-platform = "0.1.0" url = "2.1.1" -anyhow = "1.0.47" [dev-dependencies] tempfile = "3.1.0" From c9a4d41d0c0eac4d41f2393c92469a208c1a7973 Mon Sep 17 00:00:00 2001 From: Remo Senekowitsch Date: Tue, 30 Jul 2024 11:13:17 +0200 Subject: [PATCH 2/4] Bump env_logger to 0.11.0 --- Cargo.lock | 68 ++++++++++++++---------------------------------------- Cargo.toml | 2 +- 2 files changed, 18 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a598367..82abe71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -115,17 +115,6 @@ version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.3.0" @@ -264,7 +253,7 @@ dependencies = [ "hmac", "home", "http-auth", - "humantime 2.1.0", + "humantime", "ignore", "im-rc", "indexmap", @@ -766,16 +755,26 @@ dependencies = [ ] [[package]] -name = "env_logger" -version = "0.7.1" +name = "env_filter" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" dependencies = [ - "atty", - "humantime 1.3.0", "log", "regex", - "termcolor", +] + +[[package]] +name = "env_logger" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "humantime", + "log", ] [[package]] @@ -1788,15 +1787,6 @@ dependencies = [ "hashbrown", ] -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hex" version = "0.4.3" @@ -1839,15 +1829,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - [[package]] name = "humantime" version = "2.1.0" @@ -2443,12 +2424,6 @@ dependencies = [ "parking_lot", ] -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - [[package]] name = "quote" version = "1.0.36" @@ -2949,15 +2924,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "terminal_size" version = "0.3.0" diff --git a/Cargo.toml b/Cargo.toml index ba3a5d0..99c01ac 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ anyhow = "1.0.47" cargo = "0.81.0" cargo-platform = "0.1.0" docopt = "1.1.0" -env_logger = "0.7.0" +env_logger = "0.11.0" failure = "0.1.8" flate2 = "1.0.22" openssl = { version = '0.10.41', optional = true } From a5401b92ce574ee8ce7789dd22d262f86aaee81a Mon Sep 17 00:00:00 2001 From: Remo Senekowitsch Date: Tue, 30 Jul 2024 11:16:37 +0200 Subject: [PATCH 3/4] Remove unused dependency: failure --- Cargo.lock | 113 ++++++----------------------------------------------- Cargo.toml | 1 - 2 files changed, 11 insertions(+), 103 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 82abe71..078fa26 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,15 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "addr2line" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" -dependencies = [ - "gimli", -] - [[package]] name = "adler" version = "1.0.2" @@ -121,21 +112,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" -[[package]] -name = "backtrace" -version = "0.3.73" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - [[package]] name = "base16ct" version = "0.2.0" @@ -351,7 +327,6 @@ dependencies = [ "cargo-platform", "docopt", "env_logger", - "failure", "flate2", "openssl", "serde", @@ -477,7 +452,7 @@ dependencies = [ "nom", "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -803,28 +778,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "failure" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - [[package]] name = "fallible-iterator" version = "0.3.0" @@ -942,12 +895,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "gimli" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" - [[package]] name = "git2" version = "0.18.3" @@ -1363,7 +1310,7 @@ checksum = "999ce923619f88194171a67fb3e6d613653b8d4d6078b529b15a765da0edcc17" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -2071,7 +2018,7 @@ checksum = "5cf92c10c7e361d6b99666ec1c6f9805b0bea2c3bd8c78dc6fe98ac5bd78db11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -2166,15 +2113,6 @@ dependencies = [ "libc", ] -[[package]] -name = "object" -version = "0.36.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" version = "1.19.0" @@ -2216,7 +2154,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -2558,12 +2496,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "rustc-demangle" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" - [[package]] name = "rustfix" version = "0.8.4" @@ -2703,7 +2635,7 @@ checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -2867,17 +2799,6 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.72" @@ -2889,18 +2810,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-xid", -] - [[package]] name = "tar" version = "0.4.41" @@ -2951,7 +2860,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -3065,7 +2974,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -3250,7 +3159,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.72", + "syn", "wasm-bindgen-shared", ] @@ -3272,7 +3181,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3500,7 +3409,7 @@ checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] @@ -3511,7 +3420,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 99c01ac..0485b14 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,6 @@ cargo = "0.81.0" cargo-platform = "0.1.0" docopt = "1.1.0" env_logger = "0.11.0" -failure = "0.1.8" flate2 = "1.0.22" openssl = { version = '0.10.41', optional = true } serde = { version = "1.0.104", features = ['derive'] } From b229bc772282ebd74a22da62039cc37a9116ca6e Mon Sep 17 00:00:00 2001 From: Remo Senekowitsch Date: Tue, 30 Jul 2024 11:22:58 +0200 Subject: [PATCH 4/4] Fix clippy warnings --- src/main.rs | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/src/main.rs b/src/main.rs index ef984ae..7c7c224 100644 --- a/src/main.rs +++ b/src/main.rs @@ -90,7 +90,7 @@ Options: .unwrap_or_else(|e| e.exit()); let result = real_main(options, &mut config); if let Err(e) = result { - cargo::exit_with_error(e.into(), &mut *config.shell()); + cargo::exit_with_error(e.into(), &mut config.shell()); } } @@ -122,7 +122,7 @@ fn real_main(options: Options, config: &mut GlobalContext) -> CargoResult<()> { None => return Ok(()), }; - sync(Path::new(lockfile), &path, &id, &options, config).with_context(|| "failed to sync")?; + sync(Path::new(lockfile), path, &id, &options, config).with_context(|| "failed to sync")?; println!( "add this to your .cargo/config somewhere: @@ -190,7 +190,7 @@ fn sync( let gz = GzEncoder::new(file, flate2::Compression::best()); let mut ar = Builder::new(gz); ar.mode(tar::HeaderMode::Deterministic); - build_ar(&mut ar, &pkg, config); + build_ar(&mut ar, pkg, config); } added_crates.insert(dst); @@ -202,11 +202,11 @@ fn sync( 3 => index_dir.join("3").join(&name[..1]).join(name), _ => index_dir.join(&name[..2]).join(&name[2..4]).join(name), }; - fs::create_dir_all(&dst.parent().unwrap())?; - let line = serde_json::to_string(®istry_pkg(&pkg, &resolve)).unwrap(); + fs::create_dir_all(dst.parent().unwrap())?; + let line = serde_json::to_string(®istry_pkg(pkg, &resolve)).unwrap(); let prev = if no_delete || added_index.contains(&dst) { - read(&dst).unwrap_or(String::new()) + read(&dst).unwrap_or_default() } else { // If cleaning old entries (no_delete is not set), don't read the file unless we wrote // it in one of the previous iterations. @@ -255,12 +255,10 @@ fn sync( fn scan_delete(path: &Path, depth: usize, keep: &HashSet) -> CargoResult<()> { if path.is_file() && !keep.contains(path) { - fs::remove_file(&path)?; + fs::remove_file(path)?; } else if path.is_dir() && depth > 0 { - for entry in path.read_dir()? { - if let Ok(entry) = entry { - scan_delete(&entry.path(), depth - 1, keep)?; - } + for entry in (path.read_dir()?).flatten() { + scan_delete(&entry.path(), depth - 1, keep)?; } let is_empty = path.read_dir()?.next().is_none(); @@ -276,7 +274,7 @@ fn build_ar(ar: &mut Builder>, pkg: &Package, config: &GlobalCon let root = pkg.root(); let src = PathSource::new(pkg.root(), pkg.package_id().source_id(), config); for file in src.list_files(pkg).unwrap().iter() { - let relative = file.strip_prefix(&root).unwrap(); + let relative = file.strip_prefix(root).unwrap(); let relative = relative.to_str().unwrap(); let mut file = File::open(file).unwrap(); let path = format!( @@ -332,22 +330,19 @@ fn registry_pkg(pkg: &Package, resolve: &Resolve) -> RegistryPackage { let features = pkg .summary() .features() - .into_iter() - .filter_map(|(k, v)| { - let mut v = v - .iter() - .filter_map(|fv| Some(fv.to_string())) - .collect::>(); + .iter() + .map(|(k, v)| { + let mut v = v.iter().map(|fv| fv.to_string()).collect::>(); v.sort(); - Some((k.to_string(), v)) + (k.to_string(), v) }) .collect(); RegistryPackage { name: id.name().to_string(), vers: id.version().to_string(), - deps: deps, - features: features, + deps, + features, cksum: resolve .checksums() .get(&id)