Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cob: Remove support for legacy issues
cloudhead committed 2 years ago
commit 5c256c8bfba6e205e687bdd9a0289679f436da3e
parent 5fc6d960766c89051b360992a6668f7ddfe1cc3f
5 files changed +0 -143
modified 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.
modified 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;
modified radicle/src/cob/issue.rs
@@ -123,23 +123,6 @@ impl store::FromHistory for Issue {
        Ok(())
    }

-
    fn from_history<R: ReadRepository>(
-
        history: &radicle_cob::History,
-
        repo: &R,
-
    ) -> Result<Self, Self::Error> {
-
        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::<R, Self>(history, repo)
-
        }
-
    }
-

    fn apply<R: ReadRepository>(&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)?;
deleted radicle/src/cob/legacy.rs
@@ -1 +0,0 @@
-
pub mod issue;
deleted radicle/src/cob/legacy/issue.rs
@@ -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<Action>;
-
/// Error type.
-
pub type Error = issue::Error;
-

-
/// Issue state. Accumulates [`Action`].
-
#[derive(Debug, Clone, PartialEq, Eq, Default)]
-
pub struct Issue(issue::Issue);
-

-
impl From<Issue> 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<R: ReadRepository>(&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<ActorId>,
-
        remove: Vec<ActorId>,
-
    },
-
    Edit {
-
        title: String,
-
    },
-
    Lifecycle {
-
        state: issue::State,
-
    },
-
    Tag {
-
        add: Vec<Label>,
-
        remove: Vec<Label>,
-
    },
-
    Thread {
-
        action: thread::Action,
-
    },
-
}
-

-
impl HistoryAction for Action {}
-

-
impl From<thread::Action> for Action {
-
    fn from(action: thread::Action) -> Self {
-
        Self::Thread { action }
-
    }
-
}