add message trailer for commit snapshots

This commit is contained in:
Kiril Videlov 2024-05-13 01:07:42 +02:00
parent af95a898cb
commit 06dfc95692
No known key found for this signature in database
3 changed files with 14 additions and 1 deletions

View File

@ -131,6 +131,8 @@
<div>
after: {entry.details?.trailers.find((t) => t.key === 'after')?.value}
</div>
{:else if ['CreateCommit'].includes(entry.details?.operation || '')}
message: {entry.details?.trailers.find((t) => t.key === 'message')?.value}
{/if}
</div>
<div>

View File

@ -15,9 +15,19 @@ pub trait Snapshot {
old_branch: Branch,
update: BranchUpdateRequest,
) -> anyhow::Result<()>;
fn snapshot_commit_creation(&self, commit_message: String) -> anyhow::Result<()>;
}
impl<T: Oplog> Snapshot for T {
fn snapshot_commit_creation(&self, commit_message: String) -> anyhow::Result<()> {
let details =
SnapshotDetails::new(OperationType::CreateCommit).with_trailers(vec![Trailer {
key: "message".to_string(),
value: commit_message,
}]);
self.create_snapshot(details)?;
Ok(())
}
fn snapshot_branch_creation(&self, branch_name: String) -> anyhow::Result<()> {
let details =
SnapshotDetails::new(OperationType::CreateBranch).with_trailers(vec![Trailer {

View File

@ -3,6 +3,7 @@ use crate::{
ops::{
entry::{OperationType, SnapshotDetails},
oplog::Oplog,
snapshot::Snapshot,
},
};
use std::{collections::HashMap, path::Path, sync::Arc};
@ -484,7 +485,7 @@ impl ControllerInner {
let _ = project_repository
.project()
.create_snapshot(SnapshotDetails::new(OperationType::CreateCommit));
.snapshot_commit_creation(message.to_owned());
result
})
}