diff --git a/radicle-cli/src/commands/issue.rs b/radicle-cli/src/commands/issue.rs index 347b5a88..4bc90368 100644 --- a/radicle-cli/src/commands/issue.rs +++ b/radicle-cli/src/commands/issue.rs @@ -8,7 +8,7 @@ use crate::terminal as term; use crate::terminal::args::{Args, Error, Help}; use radicle::cob::common::{Reaction, Tag}; -use radicle::cob::issue::{CloseReason, IssueId, Issues, Status}; +use radicle::cob::issue::{CloseReason, IssueId, Issues, State}; use radicle::storage::WriteStorage; pub const HELP: Help = Help { @@ -59,7 +59,7 @@ pub enum Operation { }, State { id: IssueId, - state: Status, + state: State, }, Delete { id: IssueId, @@ -86,7 +86,7 @@ impl Args for Options { let mut title: Option = None; let mut reaction: Option = None; let mut description: Option = None; - let mut state: Option = None; + let mut state: Option = None; while let Some(arg) = parser.next()? { match arg { @@ -97,15 +97,15 @@ impl Args for Options { title = Some(parser.value()?.to_string_lossy().into()); } Long("closed") if op == Some(OperationName::State) => { - state = Some(Status::Closed { + state = Some(State::Closed { reason: CloseReason::Other, }); } Long("open") if op == Some(OperationName::State) => { - state = Some(Status::Open); + state = Some(State::Open); } Long("solved") if op == Some(OperationName::State) => { - state = Some(Status::Closed { + state = Some(State::Closed { reason: CloseReason::Solved, }); } diff --git a/radicle-httpd/src/api/v1/projects.rs b/radicle-httpd/src/api/v1/projects.rs index 6edcb001..69fdc0bd 100644 --- a/radicle-httpd/src/api/v1/projects.rs +++ b/radicle-httpd/src/api/v1/projects.rs @@ -333,7 +333,7 @@ async fn issues_handler( "id": id, "author": issue.author(), "title": issue.title(), - "status": issue.status(), + "status": issue.state(), "discussion": issue.comments().collect::>(), "tags": issue.tags().collect::>(), }) @@ -360,7 +360,7 @@ async fn issue_handler( "id": issue_id, "author": issue.author(), "title": issue.title(), - "status": issue.status(), + "status": issue.state(), "discussion": issue.comments().collect::>(), "tags": issue.tags().collect::>(), }); diff --git a/radicle/src/cob/issue.rs b/radicle/src/cob/issue.rs index 3d7afb6f..3c875e14 100644 --- a/radicle/src/cob/issue.rs +++ b/radicle/src/cob/issue.rs @@ -47,7 +47,7 @@ pub enum CloseReason { /// Issue state. #[derive(Debug, Default, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase", tag = "status")] -pub enum Status { +pub enum State { /// The issue is closed. Closed { reason: CloseReason }, /// The issue is open. @@ -55,7 +55,7 @@ pub enum Status { Open, } -impl std::fmt::Display for Status { +impl std::fmt::Display for State { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::Closed { .. } => write!(f, "closed"), @@ -64,11 +64,11 @@ impl std::fmt::Display for Status { } } -impl Status { +impl State { pub fn lifecycle_message(self) -> String { match self { - Status::Open => "Open issue".to_owned(), - Status::Closed { .. } => "Close issue".to_owned(), + State::Open => "Open issue".to_owned(), + State::Closed { .. } => "Close issue".to_owned(), } } } @@ -77,7 +77,7 @@ impl Status { #[derive(Debug, Clone, PartialEq, Eq)] pub struct Issue { title: LWWReg, clock::Lamport>, - status: LWWReg, clock::Lamport>, + state: LWWReg, clock::Lamport>, tags: LWWSet, thread: Thread, } @@ -85,7 +85,7 @@ pub struct Issue { impl Semilattice for Issue { fn merge(&mut self, other: Self) { self.title.merge(other.title); - self.status.merge(other.status); + self.state.merge(other.state); self.thread.merge(other.thread); } } @@ -94,7 +94,7 @@ impl Default for Issue { fn default() -> Self { Self { title: Max::from(String::default()).into(), - status: Max::from(Status::default()).into(), + state: Max::from(State::default()).into(), tags: LWWSet::default(), thread: Thread::default(), } @@ -132,8 +132,8 @@ impl Issue { self.title.get().as_str() } - pub fn status(&self) -> &Status { - self.status.get() + pub fn state(&self) -> &State { + self.state.get() } pub fn tags(&self) -> impl Iterator { @@ -161,8 +161,8 @@ impl Issue { Action::Title { title } => { self.title.set(title, op.clock); } - Action::Lifecycle { status } => { - self.status.set(status, op.clock); + Action::Lifecycle { state } => { + self.state.set(state, op.clock); } Action::Tag { add, remove } => { for tag in add { @@ -208,8 +208,8 @@ impl<'a, 'g> IssueMut<'a, 'g> { } /// Lifecycle an issue. - pub fn lifecycle(&mut self, status: Status, signer: &G) -> Result { - let action = Action::Lifecycle { status }; + pub fn lifecycle(&mut self, state: State, signer: &G) -> Result { + let action = Action::Lifecycle { state }; self.apply("Lifecycle", action, signer) } @@ -388,7 +388,7 @@ impl<'a> Issues<'a> { #[serde(tag = "type", rename_all = "camelCase")] pub enum Action { Title { title: String }, - Lifecycle { status: Status }, + Lifecycle { state: State }, Tag { add: Vec, remove: Vec }, Thread { action: thread::Action }, } @@ -411,8 +411,8 @@ mod test { fn test_ordering() { assert!(CloseReason::Solved > CloseReason::Other); assert!( - Status::Open - > Status::Closed { + State::Open + > State::Closed { reason: CloseReason::Solved } ); @@ -434,7 +434,7 @@ mod test { assert_eq!(issue.author(), Some(issues.author())); assert_eq!(issue.description(), Some("Blah blah blah.")); assert_eq!(issue.comments().count(), 1); - assert_eq!(issue.status(), &Status::Open); + assert_eq!(issue.state(), &State::Open); } #[test] @@ -448,7 +448,7 @@ mod test { issue .lifecycle( - Status::Closed { + State::Closed { reason: CloseReason::Other, }, &signer, @@ -458,15 +458,15 @@ mod test { let id = issue.id; let mut issue = issues.get_mut(&id).unwrap(); assert_eq!( - *issue.status(), - Status::Closed { + *issue.state(), + State::Closed { reason: CloseReason::Other } ); - issue.lifecycle(Status::Open, &signer).unwrap(); + issue.lifecycle(State::Open, &signer).unwrap(); let issue = issues.get(&id).unwrap().unwrap(); - assert_eq!(*issue.status(), Status::Open); + assert_eq!(*issue.state(), State::Open); } #[test] @@ -566,12 +566,12 @@ mod test { #[test] fn test_issue_state_serde() { assert_eq!( - serde_json::to_value(Status::Open).unwrap(), + serde_json::to_value(State::Open).unwrap(), serde_json::json!({ "status": "open" }) ); assert_eq!( - serde_json::to_value(Status::Closed { + serde_json::to_value(State::Closed { reason: CloseReason::Solved }) .unwrap(), diff --git a/radicle/src/cob/patch.rs b/radicle/src/cob/patch.rs index cba366b4..6a9c6f71 100644 --- a/radicle/src/cob/patch.rs +++ b/radicle/src/cob/patch.rs @@ -120,8 +120,8 @@ pub struct Patch { pub title: LWWReg>, /// Patch description. pub description: LWWReg>, - /// Current status of the patch. - pub status: LWWReg>, + /// Current state of the patch. + pub state: LWWReg>, /// Target this patch is meant to be merged in. pub target: LWWReg>, /// Associated tags. @@ -135,7 +135,7 @@ impl Semilattice for Patch { fn merge(&mut self, other: Self) { self.title.merge(other.title); self.description.merge(other.description); - self.status.merge(other.status); + self.state.merge(other.state); self.target.merge(other.target); self.tags.merge(other.tags); self.revisions.merge(other.revisions); @@ -147,7 +147,7 @@ impl Default for Patch { Self { title: Max::from(String::default()).into(), description: Max::from(String::default()).into(), - status: Max::from(Status::default()).into(), + state: Max::from(State::default()).into(), target: Max::from(MergeTarget::default()).into(), tags: LWWSet::default(), revisions: GMap::default(), @@ -160,8 +160,8 @@ impl Patch { self.title.get().get() } - pub fn status(&self) -> Status { - *self.status.get().get() + pub fn state(&self) -> State { + *self.state.get().get() } pub fn target(&self) -> MergeTarget { @@ -217,11 +217,11 @@ impl Patch { } pub fn is_proposed(&self) -> bool { - matches!(self.status.get().get(), Status::Proposed) + matches!(self.state.get().get(), State::Proposed) } pub fn is_archived(&self) -> bool { - matches!(self.status.get().get(), &Status::Archived) + matches!(self.state.get().get(), &State::Archived) } /// Apply a list of operations to the state. @@ -383,7 +383,7 @@ impl Revision { #[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -pub enum Status { +pub enum State { #[default] Proposed, Draft, @@ -978,7 +978,7 @@ mod test { assert_eq!(patch.title(), "My first patch"); assert_eq!(patch.description(), Some("Blah blah blah.")); assert_eq!(patch.author().id(), &author); - assert_eq!(patch.status(), Status::Proposed); + assert_eq!(patch.state(), State::Proposed); assert_eq!(patch.target(), target); assert_eq!(patch.version(), 0);