Record entering edit mode in oplog

This commit is contained in:
Caleb Owens 2024-08-19 11:44:59 +02:00
parent 7ab7731a31
commit dbe8013de3
6 changed files with 25 additions and 2 deletions

1
Cargo.lock generated
View File

@ -2206,6 +2206,7 @@ dependencies = [
"gitbutler-command-context",
"gitbutler-commit",
"gitbutler-operating-modes",
"gitbutler-oplog",
"gitbutler-project",
"gitbutler-reference",
"gitbutler-repo",

View File

@ -144,6 +144,8 @@
return { text: 'Update workspace base', icon: 'rebase' };
case 'RestoreFromSnapshot':
return { text: 'Revert snapshot', icon: 'empty' };
case 'EnterEditMode':
return { text: 'Enter Edit Mode', icon: 'edit-text' };
default:
return { text: snapshotDetails.operation, icon: 'commit' };
}

View File

@ -29,7 +29,8 @@ export type Operation =
| 'ReorderCommit'
| 'InsertBlankCommit'
| 'MoveCommitFile'
| 'FileChanges';
| 'FileChanges'
| 'EnterEditMode';
export class Trailer {
key!: string;

View File

@ -18,3 +18,4 @@ gitbutler-project.workspace = true
gitbutler-branch-actions.workspace = true
gitbutler-reference.workspace = true
gitbutler-time.workspace = true
gitbutler-oplog.workspace = true

View File

@ -1,6 +1,10 @@
use anyhow::{Context, Result};
use gitbutler_command_context::CommandContext;
use gitbutler_operating_modes::{assure_edit_mode, assure_open_workspace_mode, EditModeMetadata};
use gitbutler_oplog::{
entry::{OperationKind, SnapshotDetails},
OplogExt,
};
use gitbutler_project::{access::WriteWorkspaceGuard, Project};
use gitbutler_reference::ReferenceName;
@ -24,7 +28,20 @@ pub fn enter_edit_mode(
.find_reference(&editee_branch)
.context("Failed to find editee branch reference")?;
crate::enter_edit_mode(&ctx, &editee, &editee_branch, guard.write_permission())
let snapshot = project
.prepare_snapshot(guard.read_permission())
.context("Failed to prepare snapshot")?;
let edit_mode_metadata =
crate::enter_edit_mode(&ctx, &editee, &editee_branch, guard.write_permission())?;
let _ = project.commit_snapshot(
snapshot,
SnapshotDetails::new(OperationKind::EnterEditMode),
guard.write_permission(),
);
Ok(edit_mode_metadata)
}
pub fn save_and_return_to_workspace(project: &Project) -> Result<()> {

View File

@ -155,6 +155,7 @@ pub enum OperationKind {
InsertBlankCommit,
MoveCommitFile,
FileChanges,
EnterEditMode,
#[default]
Unknown,
}