diff --git a/radicle-httpd/src/api/v1/projects.rs b/radicle-httpd/src/api/v1/projects.rs index 5c9f0d90..1cd11fc3 100644 --- a/radicle-httpd/src/api/v1/projects.rs +++ b/radicle-httpd/src/api/v1/projects.rs @@ -626,6 +626,12 @@ async fn patch_update_handler( } => { patch.edit(title, description, target, &signer)?; } + patch::Action::EditRevision { + revision, + description, + } => { + patch.edit_revision(revision, description, &signer)?; + } patch::Action::Tag { add, remove } => { patch.tag(add, remove, &signer)?; } diff --git a/radicle/src/cob/patch.rs b/radicle/src/cob/patch.rs index 0cbad7fb..12df1867 100644 --- a/radicle/src/cob/patch.rs +++ b/radicle/src/cob/patch.rs @@ -80,6 +80,10 @@ pub enum Action { description: String, target: MergeTarget, }, + EditRevision { + revision: RevisionId, + description: String, + }, Tag { add: Vec, remove: Vec, @@ -273,6 +277,16 @@ impl store::FromHistory for Patch { self.tags.remove(tag, op.clock); } } + Action::EditRevision { + revision, + description, + } => { + if let Some(Redactable::Present(revision)) = self.revisions.get_mut(&revision) { + revision.description.set(description, op.clock); + } else { + return Err(ApplyError::Missing(revision)); + } + } Action::Revision { description, base, @@ -606,6 +620,17 @@ impl store::Transaction { }) } + pub fn edit_revision( + &mut self, + revision: RevisionId, + description: impl ToString, + ) -> Result<(), store::Error> { + self.push(Action::EditRevision { + revision, + description: description.to_string(), + }) + } + /// Start a patch revision discussion. pub fn thread( &mut self, @@ -744,6 +769,18 @@ impl<'a, 'g> PatchMut<'a, 'g> { self.transaction("Edit", signer, |tx| tx.edit(title, description, target)) } + /// Edit revision metadata. + pub fn edit_revision( + &mut self, + revision: RevisionId, + description: String, + signer: &G, + ) -> Result { + self.transaction("Edit Revision", signer, |tx| { + tx.edit_revision(revision, description) + }) + } + /// Create a thread on a patch revision. pub fn thread( &mut self,