Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cob: Add `patch::Action::EditRevision`
Sebastian Martinez committed 3 years ago
commit c9aaaec2eeb2ac12eeda6b936eb40e34752bccd1
parent fa15ca59f18ad6c4714cd47b592e0d0f6628cdbc
2 files changed +43 -0
modified 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)?;
        }
modified radicle/src/cob/patch.rs
@@ -80,6 +80,10 @@ pub enum Action {
        description: String,
        target: MergeTarget,
    },
+
    EditRevision {
+
        revision: RevisionId,
+
        description: String,
+
    },
    Tag {
        add: Vec<Tag>,
        remove: Vec<Tag>,
@@ -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<Patch> {
        })
    }

+
    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<S: ToString>(
        &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<G: Signer>(
+
        &mut self,
+
        revision: RevisionId,
+
        description: String,
+
        signer: &G,
+
    ) -> Result<EntryId, Error> {
+
        self.transaction("Edit Revision", signer, |tx| {
+
            tx.edit_revision(revision, description)
+
        })
+
    }
+

    /// Create a thread on a patch revision.
    pub fn thread<G: Signer, S: ToString>(
        &mut self,