Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
httpd: Add `patch::Action::Lifecycle`
Sebastian Martinez committed 3 years ago
commit 8907ddb8a5169baf305e759963a5bea8dae935c2
parent c9aaaec2eeb2ac12eeda6b936eb40e34752bccd1
2 files changed +19 -0
modified radicle-httpd/src/api/v1/projects.rs
@@ -645,6 +645,9 @@ async fn patch_update_handler(
        patch::Action::Redact { .. } => {
            todo!()
        }
+
        patch::Action::Lifecycle { state } => {
+
            patch.lifecycle(state, &signer)?;
+
        }
        patch::Action::Review {
            revision,
            comment,
modified radicle/src/cob/patch.rs
@@ -93,6 +93,9 @@ pub enum Action {
        base: git::Oid,
        oid: git::Oid,
    },
+
    Lifecycle {
+
        state: State,
+
    },
    Redact {
        revision: RevisionId,
    },
@@ -269,6 +272,9 @@ impl store::FromHistory for Patch {
                    self.description.set(description, op.clock);
                    self.target.set(target, op.clock);
                }
+
                Action::Lifecycle { state } => {
+
                    self.state.set(state, op.clock);
+
                }
                Action::Tag { add, remove } => {
                    for tag in add {
                        self.tags.insert(tag, op.clock);
@@ -697,6 +703,11 @@ impl store::Transaction<Patch> {
        })
    }

+
    /// Lifecycle a patch.
+
    pub fn lifecycle(&mut self, state: State) -> Result<(), store::Error> {
+
        self.push(Action::Lifecycle { state })
+
    }
+

    /// Tag a patch.
    pub fn tag(
        &mut self,
@@ -839,6 +850,11 @@ impl<'a, 'g> PatchMut<'a, 'g> {
        })
    }

+
    /// Lifecycle a patch.
+
    pub fn lifecycle<G: Signer>(&mut self, state: State, signer: &G) -> Result<EntryId, Error> {
+
        self.transaction("Lifecycle", signer, |tx| tx.lifecycle(state))
+
    }
+

    /// Tag a patch.
    pub fn tag<G: Signer>(
        &mut self,