Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
Rename patch/issue "status"
Alexis Sellier committed 3 years ago
commit 5d2be57cd9fd8ce1698dd5c65f660f945d5c125c
parent de0e54a186f3b7fa4116b5d39d4cef556dcf64e3
4 files changed +43 -43
modified 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<String> = None;
        let mut reaction: Option<Reaction> = None;
        let mut description: Option<String> = None;
-
        let mut state: Option<Status> = None;
+
        let mut state: Option<State> = 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,
                    });
                }
modified 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::<Vec<_>>(),
                "tags": issue.tags().collect::<Vec<_>>(),
            })
@@ -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::<Vec<_>>(),
        "tags": issue.tags().collect::<Vec<_>>(),
    });
modified 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<Max<String>, clock::Lamport>,
-
    status: LWWReg<Max<Status>, clock::Lamport>,
+
    state: LWWReg<Max<State>, clock::Lamport>,
    tags: LWWSet<Tag>,
    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<Item = &Tag> {
@@ -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<G: Signer>(&mut self, status: Status, signer: &G) -> Result<OpId, Error> {
-
        let action = Action::Lifecycle { status };
+
    pub fn lifecycle<G: Signer>(&mut self, state: State, signer: &G) -> Result<OpId, Error> {
+
        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<Tag>, remove: Vec<Tag> },
    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(),
modified radicle/src/cob/patch.rs
@@ -120,8 +120,8 @@ pub struct Patch {
    pub title: LWWReg<Max<String>>,
    /// Patch description.
    pub description: LWWReg<Max<String>>,
-
    /// Current status of the patch.
-
    pub status: LWWReg<Max<Status>>,
+
    /// Current state of the patch.
+
    pub state: LWWReg<Max<State>>,
    /// Target this patch is meant to be merged in.
    pub target: LWWReg<Max<MergeTarget>>,
    /// 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);