Skip to content

Commit 3831937

Browse files
committed
feat!: Add support for detecting deleted crates.
Previously there was no need to do that as deletions couldn't happen - crates are yanked instead. Now that the ecosystem experienced its first (known) supply-chain attack crates can also be deleted and we should be able to detect that to allow downstream users to act on this automatically.
1 parent 40655bd commit 3831937

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/index.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use super::{Change, CrateVersion};
22
use std::path::Path;
33

44
use git2::{
5-
build::RepoBuilder, Delta, Error as GitError, ErrorClass, Object, ObjectType, Oid,
6-
Reference, Repository, Tree,
5+
build::RepoBuilder, Delta, Error as GitError, ErrorClass, Object, ObjectType, Oid, Reference,
6+
Repository, Tree,
77
};
88
use std::str;
99

@@ -23,7 +23,9 @@ pub struct Index {
2323

2424
/// Options for use in `Index::from_path_or_cloned_with_options`
2525
pub struct CloneOptions<'a> {
26+
/// The url from which the repository should be cloned.
2627
pub repository_url: String,
28+
/// Git2 fetch options to control exactly how to clone.
2729
pub fetch_options: Option<git2::FetchOptions<'a>>,
2830
}
2931

@@ -307,7 +309,9 @@ impl Index {
307309
return true;
308310
}
309311

310-
if let Ok(crate_version) = serde_json::from_slice::<CrateVersion>(diffline.content()) {
312+
if let Ok(crate_version) =
313+
serde_json::from_slice::<CrateVersion>(diffline.content())
314+
{
311315
if crate_version.yanked {
312316
changes.push(Change::Yanked(crate_version));
313317
} else {

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//!
33
//! Have a look at the real-world usage to learn more about it:
44
//! [crates-io-cli](https://github.com/Byron/crates-io-cli-rs/blob/b7a39ad8ef68adb81b2d8a7e552cb0a2a73f7d5b/src/main.rs#L62)
5+
#![forbid(missing_docs)]
56
#[macro_use]
67
extern crate serde_derive;
78

0 commit comments

Comments
 (0)