Skip to content

Commit

Permalink
chore!: remove changes feature
Browse files Browse the repository at this point in the history
It only gated a little bit of code, but no dependencies. Thus it had no considerable
effect on build times and can be removed.
  • Loading branch information
Byron committed Jul 29, 2023
1 parent aba9606 commit 260c103
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cargo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down Expand Up @@ -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"]
Expand Down
41 changes: 24 additions & 17 deletions src/bare_index.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 <https://crates.io/data-access> instead.
#[cfg(feature = "changes")]
pub fn changes(&self) -> Result<ChangesIter<'_>, Error> {
Ok(ChangesIter::new(self)?)
}
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
//!
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 260c103

Please sign in to comment.