-
Notifications
You must be signed in to change notification settings - Fork 8
feat(quarantine): persist quarantine resolution mode in meta.json #1148
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,11 @@ | ||
| mod bundle_meta; | ||
| mod bundler; | ||
| mod files; | ||
| mod quarantine_resolution_mode; | ||
| mod types; | ||
|
|
||
| pub use bundle_meta::*; | ||
| pub use bundler::*; | ||
| pub use files::*; | ||
| pub use quarantine_resolution_mode::*; | ||
| pub use types::*; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| use context::repo::RepoUrlParts; | ||
| #[cfg(feature = "pyo3")] | ||
| use pyo3::prelude::*; | ||
| #[cfg(feature = "pyo3")] | ||
| use pyo3_stub_gen::derive::gen_stub_pyclass_enum; | ||
| use serde::{Deserialize, Serialize}; | ||
| #[cfg(feature = "wasm")] | ||
| use tsify_next::Tsify; | ||
|
|
||
| /// Which source the server resolved quarantine status from. | ||
| #[derive(Debug, Serialize, Clone, Copy, PartialEq, Eq, Default)] | ||
| #[cfg_attr(feature = "pyo3", gen_stub_pyclass_enum, pyclass(eq, eq_int))] | ||
| #[cfg_attr(feature = "wasm", derive(Tsify))] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub enum QuarantineResolutionMode { | ||
| Repo, | ||
| TestCollection, | ||
| #[default] | ||
| Unspecified, | ||
| } | ||
|
|
||
| impl<'de> Deserialize<'de> for QuarantineResolutionMode { | ||
| fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | ||
| where | ||
| D: serde::Deserializer<'de>, | ||
| { | ||
| Ok( | ||
| match serde_json::Value::deserialize(deserializer)?.as_str() { | ||
| Some("repo") => Self::Repo, | ||
| Some("test_collection") => Self::TestCollection, | ||
| _ => Self::Unspecified, | ||
| }, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| impl From<QuarantineResolutionMode> for proto::upload_metrics::trunk::QuarantineResolutionMode { | ||
| fn from(mode: QuarantineResolutionMode) -> Self { | ||
| match mode { | ||
| QuarantineResolutionMode::Repo => Self::Repo, | ||
| QuarantineResolutionMode::TestCollection => Self::TestCollection, | ||
| QuarantineResolutionMode::Unspecified => Self::Unspecified, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl QuarantineResolutionMode { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I love rust sometimes |
||
| pub fn resolution_log_line( | ||
| &self, | ||
| test_collection_id: Option<&str>, | ||
| repo: &RepoUrlParts, | ||
| ) -> Option<String> { | ||
| match self { | ||
| Self::TestCollection => Some(format!( | ||
| "Quarantine status applied from test collection {}", | ||
| test_collection_id.unwrap_or("unknown"), | ||
| )), | ||
| Self::Repo => Some(format!( | ||
| "Quarantine status applied from repo {}", | ||
| repo.repo_full_name() | ||
| )), | ||
| Self::Unspecified => None, | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+47
to
+65
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is just ported but optional note on copy:
Resolved imo doesn't make much sense to the user since that's a bit internal to us |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file's diff is just moving code to the
bundlecrate to avoid circular import