diff --git a/radicle-httpd/src/api/v1/projects.rs b/radicle-httpd/src/api/v1/projects.rs index 1cd11fc3..4aa6f8a2 100644 --- a/radicle-httpd/src/api/v1/projects.rs +++ b/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, diff --git a/radicle/src/cob/patch.rs b/radicle/src/cob/patch.rs index 12df1867..fbfecd09 100644 --- a/radicle/src/cob/patch.rs +++ b/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 { }) } + /// 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(&mut self, state: State, signer: &G) -> Result { + self.transaction("Lifecycle", signer, |tx| tx.lifecycle(state)) + } + /// Tag a patch. pub fn tag( &mut self,