mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2025-01-01 14:04:57 +03:00
snapshots of (un)appy branches contains name
This commit is contained in:
parent
158ed5c15d
commit
631bc86031
@ -122,7 +122,7 @@
|
||||
restored_from: {entry.details?.trailers
|
||||
.find((t) => t.key === 'restored_from')
|
||||
?.value?.slice(0, 7)}
|
||||
{:else if ['DeleteBranch', 'CreateBranch'].includes(entry.details?.operation || '')}
|
||||
{:else if ['DeleteBranch', 'CreateBranch', 'ApplyBranch', 'UnapplyBranch'].includes(entry.details?.operation || '')}
|
||||
name: {entry.details?.trailers.find((t) => t.key === 'name')?.value}
|
||||
{:else if ['ReorderBranches', 'UpdateBranchName', 'SelectDefaultVirtualBranch', 'UpdateBranchRemoteName'].includes(entry.details?.operation || '')}
|
||||
<div>
|
||||
|
@ -10,6 +10,8 @@ use super::{entry::Trailer, oplog::Oplog};
|
||||
pub trait Snapshot {
|
||||
fn snapshot_branch_creation(&self, branch_name: String) -> anyhow::Result<()>;
|
||||
fn snapshot_branch_deletion(&self, branch_name: String) -> anyhow::Result<()>;
|
||||
fn snapshot_branch_applied(&self, branch_name: String) -> anyhow::Result<()>;
|
||||
fn snapshot_branch_unapplied(&self, branch_name: String) -> anyhow::Result<()>;
|
||||
fn snapshot_branch_update(
|
||||
&self,
|
||||
old_branch: Branch,
|
||||
@ -24,6 +26,24 @@ pub trait Snapshot {
|
||||
}
|
||||
|
||||
impl<T: Oplog> Snapshot for T {
|
||||
fn snapshot_branch_applied(&self, branch_name: String) -> anyhow::Result<()> {
|
||||
let details =
|
||||
SnapshotDetails::new(OperationType::ApplyBranch).with_trailers(vec![Trailer {
|
||||
key: "name".to_string(),
|
||||
value: branch_name,
|
||||
}]);
|
||||
self.create_snapshot(details)?;
|
||||
Ok(())
|
||||
}
|
||||
fn snapshot_branch_unapplied(&self, branch_name: String) -> anyhow::Result<()> {
|
||||
let details =
|
||||
SnapshotDetails::new(OperationType::UnapplyBranch).with_trailers(vec![Trailer {
|
||||
key: "name".to_string(),
|
||||
value: branch_name,
|
||||
}]);
|
||||
self.create_snapshot(details)?;
|
||||
Ok(())
|
||||
}
|
||||
fn snapshot_commit_undo(&self, commit_sha: String) -> anyhow::Result<()> {
|
||||
let details =
|
||||
SnapshotDetails::new(OperationType::UndoCommit).with_trailers(vec![Trailer {
|
||||
|
@ -715,9 +715,6 @@ impl ControllerInner {
|
||||
let result =
|
||||
super::apply_branch(project_repository, branch_id, signing_key.as_ref(), user)
|
||||
.map_err(Into::into);
|
||||
let _ = project_repository
|
||||
.project()
|
||||
.create_snapshot(SnapshotDetails::new(OperationType::ApplyBranch));
|
||||
result
|
||||
})
|
||||
}
|
||||
@ -883,13 +880,18 @@ impl ControllerInner {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository, _| {
|
||||
let result = super::unapply_branch(project_repository, branch_id)
|
||||
.map(|_| ())
|
||||
.map_err(Into::into);
|
||||
let result = super::unapply_branch(project_repository, branch_id);
|
||||
let branch_name = result
|
||||
.as_ref()
|
||||
.ok()
|
||||
.cloned()
|
||||
.flatten()
|
||||
.map(|b| b.name)
|
||||
.unwrap_or_default();
|
||||
let _ = project_repository
|
||||
.project()
|
||||
.create_snapshot(SnapshotDetails::new(OperationType::UnapplyBranch));
|
||||
result
|
||||
.snapshot_branch_unapplied(branch_name);
|
||||
result.map(|_| ()).map_err(Into::into)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -453,7 +453,7 @@ pub fn apply_branch(
|
||||
|
||||
// apply the branch
|
||||
branch.applied = true;
|
||||
vb_state.set_branch(branch)?;
|
||||
vb_state.set_branch(branch.clone())?;
|
||||
|
||||
ensure_selected_for_changes(&vb_state).context("failed to ensure selected for changes")?;
|
||||
|
||||
@ -465,6 +465,9 @@ pub fn apply_branch(
|
||||
|
||||
super::integration::update_gitbutler_integration(&vb_state, project_repository)?;
|
||||
|
||||
_ = project_repository
|
||||
.project()
|
||||
.snapshot_branch_applied(branch.name);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user