Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased

- Fixed `cargo supply-chain update` failing after crates.io removed `gh_login` from its user CSV dump, while preserving compatibility with existing caches

## v0.3.7 (2026-02-05)

- Updated the caching code to handle the recent changes to crates.io dump format
Expand Down
38 changes: 38 additions & 0 deletions src/crates_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ struct User {
id: u64,
gh_avatar: Option<String>,
gh_id: Option<String>,
// Accept the dump's new field name while preserving the JSON cache format.
#[serde(alias = "username")]
gh_login: String,
name: Option<String>,
}
Expand Down Expand Up @@ -395,6 +397,42 @@ fn read_csv_data<T: serde::de::DeserializeOwned>(
reader.deserialize().collect()
}

#[cfg(test)]
mod tests {
use super::{read_csv_data, User};
use serde_json::json;

#[test]
fn current_user_csv_preserves_cache_format() {
let csv = "created_at,gh_id,id,name,username\n2026-10-01,123,42,Example,example\n";
let users: Vec<User> = read_csv_data(csv.as_bytes()).unwrap();
assert_eq!(users.len(), 1);
assert_eq!(
serde_json::to_value(&users[0]).unwrap(),
json!({
"id": 42,
"gh_avatar": null,
"gh_id": "123",
"gh_login": "example",
"name": "Example"
})
);
}

#[test]
fn existing_user_cache_round_trips() {
let cached = json!({
"id": 42,
"gh_avatar": "https://example.com/avatar.png",
"gh_id": "123",
"gh_login": "example",
"name": "Example"
});
let user: User = serde_json::from_value(cached.clone()).unwrap();
assert_eq!(serde_json::to_value(user).unwrap(), cached);
}
}

impl MetadataStored {
fn validate(&self, max_age: Duration) -> Option<bool> {
match self.age() {
Expand Down
Loading