cob: Remove support for legacy issues
This commit is contained in:
parent
5fc6d96076
commit
5c256c8bfb
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)?;
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
pub mod issue;
|
||||
|
|
@ -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 }
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue