httpd: Add `patch::Action::Lifecycle`

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
Sebastian Martinez 2023-03-30 10:43:03 +02:00 committed by Alexis Sellier
parent c9aaaec2ee
commit 8907ddb8a5
No known key found for this signature in database
2 changed files with 19 additions and 0 deletions

View File

@ -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,

View File

@ -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,