cob: Add `patch::Action::EditRevision`
To be able to change the description of a patch revision, without the need to create a new revision. Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
parent
fa15ca59f1
commit
c9aaaec2ee
|
|
@ -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)?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue