Skip to content

Improve error message for cache info serialization #8500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2024
Merged
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
41 changes: 0 additions & 41 deletions crates/uv-cache-info/src/cache_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub enum CacheInfoError {
/// timestamps of relevant files, the current commit of a repository, etc.
#[derive(Default, Debug, Clone, Hash, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(try_from = "CacheInfoWire")]
pub struct CacheInfo {
/// The timestamp of the most recent `ctime` of any relevant files, at the time of the build.
/// The timestamp will typically be the maximum of the `ctime` values of the `pyproject.toml`,
Expand Down Expand Up @@ -200,46 +199,6 @@ impl CacheInfo {
}
}

#[derive(Debug, serde::Deserialize)]
struct TimestampCommit {
#[serde(default)]
timestamp: Option<Timestamp>,
#[serde(default)]
commit: Option<Commit>,
#[serde(default)]
tags: Option<Tags>,
}

#[derive(Debug, serde::Deserialize)]
#[serde(untagged)]
enum CacheInfoWire {
/// For backwards-compatibility, enable deserializing [`CacheInfo`] structs that are solely
/// represented by a timestamp.
Timestamp(Timestamp),
/// A [`CacheInfo`] struct that includes both a timestamp and a commit.
TimestampCommit(TimestampCommit),
}

impl From<CacheInfoWire> for CacheInfo {
fn from(wire: CacheInfoWire) -> Self {
match wire {
CacheInfoWire::Timestamp(timestamp) => Self {
timestamp: Some(timestamp),
..Self::default()
},
CacheInfoWire::TimestampCommit(TimestampCommit {
timestamp,
commit,
tags,
}) => Self {
timestamp,
commit,
tags,
},
}
}
}

/// A `pyproject.toml` with an (optional) `[tool.uv]` section.
#[derive(Debug, Deserialize)]
#[serde(rename_all = "kebab-case")]
Expand Down
Loading