From 5c256c8bfba6e205e687bdd9a0289679f436da3e Mon Sep 17 00:00:00 2001 From: cloudhead Date: Wed, 6 Sep 2023 20:44:11 +0200 Subject: [PATCH] cob: Remove support for legacy issues --- radicle-cob/src/change/store.rs | 5 -- radicle/src/cob.rs | 1 - radicle/src/cob/issue.rs | 17 ----- radicle/src/cob/legacy.rs | 1 - radicle/src/cob/legacy/issue.rs | 119 -------------------------------- 5 files changed, 143 deletions(-) delete mode 100644 radicle/src/cob/legacy.rs delete mode 100644 radicle/src/cob/legacy/issue.rs diff --git a/radicle-cob/src/change/store.rs b/radicle-cob/src/change/store.rs index 16deac6d..0cb588f2 100644 --- a/radicle-cob/src/change/store.rs +++ b/radicle-cob/src/change/store.rs @@ -157,11 +157,6 @@ impl Manifest { _history_type: None, } } - - /// Whether this is an old COB. Remove this function when support for legacy COBs is over. - pub fn is_legacy(&self) -> bool { - self._history_type.is_some() - } } /// COB version. diff --git a/radicle/src/cob.rs b/radicle/src/cob.rs index 74847554..fbd8ec04 100644 --- a/radicle/src/cob.rs +++ b/radicle/src/cob.rs @@ -1,7 +1,6 @@ pub mod common; pub mod identity; pub mod issue; -pub mod legacy; pub mod op; pub mod patch; pub mod store; diff --git a/radicle/src/cob/issue.rs b/radicle/src/cob/issue.rs index baae8fd9..80cb884b 100644 --- a/radicle/src/cob/issue.rs +++ b/radicle/src/cob/issue.rs @@ -123,23 +123,6 @@ impl store::FromHistory for Issue { Ok(()) } - fn from_history( - history: &radicle_cob::History, - repo: &R, - ) -> Result { - let root = history.root(); - - // Deprecated. Remove when we drop legacy support. - if root.manifest.is_legacy() { - let legacy = super::legacy::issue::Issue::from_history(history, repo)?; - let issue = legacy.into(); - - Ok(issue) - } else { - store::from_history::(history, repo) - } - } - fn apply(&mut self, op: Op, repo: &R) -> Result<(), Error> { for action in op.actions { self.action(action, op.id, op.author, op.timestamp, op.identity, repo)?; diff --git a/radicle/src/cob/legacy.rs b/radicle/src/cob/legacy.rs deleted file mode 100644 index d93d369f..00000000 --- a/radicle/src/cob/legacy.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod issue; diff --git a/radicle/src/cob/legacy/issue.rs b/radicle/src/cob/legacy/issue.rs deleted file mode 100644 index 8358d204..00000000 --- a/radicle/src/cob/legacy/issue.rs +++ /dev/null @@ -1,119 +0,0 @@ -use serde::{Deserialize, Serialize}; - -use crate::cob; -use crate::cob::common::Label; -use crate::cob::issue; -use crate::cob::store::HistoryAction; -use crate::cob::thread; -use crate::cob::{store, ActorId, TypeName}; -use crate::prelude::ReadRepository; - -/// Issue operation. -pub type Op = cob::Op; -/// Error type. -pub type Error = issue::Error; - -/// Issue state. Accumulates [`Action`]. -#[derive(Debug, Clone, PartialEq, Eq, Default)] -pub struct Issue(issue::Issue); - -impl From for issue::Issue { - fn from(issue: Issue) -> issue::Issue { - issue.0 - } -} - -impl store::FromHistory for Issue { - type Action = Action; - type Error = Error; - - fn type_name() -> &'static TypeName { - &issue::TYPENAME - } - - fn validate(&self) -> Result<(), Self::Error> { - if self.0.title.is_empty() { - return Err(Error::Validate("title is empty")); - } - if self.0.thread.validate().is_err() { - return Err(Error::Validate("invalid thread")); - } - Ok(()) - } - - fn apply(&mut self, op: Op, repo: &R) -> Result<(), Error> { - let issue = &mut self.0; - - for action in op.actions { - match action { - Action::Assign { add, remove } => { - for assignee in add { - issue.assignees.insert(assignee.into()); - } - for assignee in remove { - issue.assignees.remove(&assignee.into()); - } - } - Action::Edit { title } => { - issue.title = title; - } - Action::Lifecycle { state } => { - issue.state = state; - } - Action::Tag { add, remove } => { - for tag in add { - issue.labels.insert(tag); - } - for tag in remove { - issue.labels.remove(&tag); - } - } - Action::Thread { action } => { - issue.thread.apply( - cob::Op::new( - op.id, - action, - op.author, - op.timestamp, - op.identity, - op.manifest.clone(), - ), - repo, - )?; - } - } - } - Ok(()) - } -} - -/// Issue operation. -#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)] -#[serde(tag = "type", rename_all = "camelCase")] -pub enum Action { - Assign { - add: Vec, - remove: Vec, - }, - Edit { - title: String, - }, - Lifecycle { - state: issue::State, - }, - Tag { - add: Vec