From 260c103409ff08a96c465568363675d6dc8a2fa7 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sat, 29 Jul 2023 10:45:37 +0200 Subject: [PATCH] chore!: remove `changes` feature It only gated a little bit of code, but no dependencies. Thus it had no considerable effect on build times and can be removed. --- .github/workflows/cargo.yml | 2 +- Cargo.toml | 5 ----- src/bare_index.rs | 41 ++++++++++++++++++++++--------------- src/lib.rs | 4 +--- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/cargo.yml b/.github/workflows/cargo.yml index 6e914e16..359cee5a 100644 --- a/.github/workflows/cargo.yml +++ b/.github/workflows/cargo.yml @@ -26,7 +26,7 @@ jobs: - uses: actions-rs/cargo@v1 with: command: test - args: --features=sparse-http,ssh,changes,git-index-performance --release + args: --features=sparse-http,ssh,git-index-performance --release - uses: actions-rs/cargo@v1 with: command: check diff --git a/Cargo.toml b/Cargo.toml index b269b6a0..48f47fc7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,10 +20,6 @@ required-features = ["sparse-http"] name = "sparse_http_ureq" required-features = ["sparse-http"] -[[example]] -name = "update_and_get_latest" -required-features = ["changes"] - [dependencies] gix = { version = "0.50.0", default-features = false, features = ["max-performance-safe", "blocking-network-client"], optional = true } hex = { version = "0.4.3", features = ["serde"] } @@ -55,7 +51,6 @@ features = ["sparse-http"] [features] default = ["git-index", "https", "parallel"] -changes = ["git-index"] git-index = ["dep:gix"] git-index-performance = ["git-index", "gix?/max-performance"] https = ["git-index", "gix?/blocking-http-transport-curl"] diff --git a/src/bare_index.rs b/src/bare_index.rs index d53c8edf..3e791203 100644 --- a/src/bare_index.rs +++ b/src/bare_index.rs @@ -1,5 +1,4 @@ #![allow(clippy::result_large_err)] -#[cfg(feature = "changes")] use crate::changes::ChangesIter; use crate::dedupe::DedupeContext; use crate::dirs::get_index_details; @@ -84,7 +83,6 @@ impl Index { /// Crates will be reported multiple times, once for each publish/yank/unyank event that happened. /// /// If you like to know publication dates of all crates, consider instead. - #[cfg(feature = "changes")] pub fn changes(&self) -> Result, Error> { Ok(ChangesIter::new(self)?) } @@ -518,23 +516,32 @@ mod test { #[test] #[cfg_attr(debug_assertions, ignore = "too slow in debug mode")] fn parse_all_blobs() { - let index = shared_index(); - - let mut ctx = DedupeContext::new(); - - let mut found_gcc_crate = false; - for c in index.crates_blobs().unwrap() { - match c.parse(&mut ctx) { - Ok(c) => { - if c.name() == "gcc" { - found_gcc_crate = true; + std::thread::scope(|scope| { + let (tx, rx) = std::sync::mpsc::channel(); + let blobs = scope.spawn(move || { + let index = shared_index(); + for c in index.crates_blobs().unwrap() { + tx.send(c).unwrap(); + } + }); + let parse = scope.spawn(move || { + let mut found_gcc_crate = false; + let mut ctx = DedupeContext::new(); + for c in rx { + match c.parse(&mut ctx) { + Ok(c) => { + if c.name() == "gcc" { + found_gcc_crate = true; + } + } + Err(e) => panic!("can't parse :( {:?}: {e}", c.0.as_bstr()), } } - Err(e) => panic!("can't parse :( {:?}: {e}", c.0.as_bstr()), - } - } - - assert!(found_gcc_crate); + assert!(found_gcc_crate); + }); + parse.join().unwrap(); + blobs.join().unwrap(); + }); } fn shared_index() -> Index { diff --git a/src/lib.rs b/src/lib.rs index df25a081..556aff00 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,10 +52,9 @@ //! # Ok::<_, crates_index::Error>(()) //! ``` //! -//! ### Getting most recently published or yanked crates (enable the `changes` feature!) +//! ### Getting most recently published or yanked crates //! //! ```rust -//! # #![cfg(feature = "changes")] //! # { //! let index = crates_index::Index::new_cargo_default()?; //! @@ -118,7 +117,6 @@ use std::sync::Arc; mod bare_index; mod config; mod dedupe; -#[cfg(feature = "changes")] mod changes; mod dirs; /// Re-exports in case you want to inspect specific error details