Skip to content

Commit 3e37bea

Browse files
committed
Ensure a checkpoint titled "Before checkpoint restored" is created before restoring a checkpoint, unless confirmation is skipped
1 parent f6c2d94 commit 3e37bea

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎packages/vscode/src/commands/checkpoints-command/actions/restore-checkpoint.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import * as vscode from 'vscode'
22
import { TEMPORARY_CHECKPOINT_STATE_KEY } from '../../../constants/state-keys'
33
import { WorkspaceProvider } from '../../../context/providers/workspace-provider'
44
import type { Checkpoint } from '../types'
5+
import { create_checkpoint } from './create-checkpoint'
56
import { create_temporary_checkpoint } from './create-temporary-checkpoint'
67
import { delete_checkpoint } from './delete-checkpoint'
8+
import { get_checkpoints } from './get-checkpoints'
79
import { sync_workspace_from_dir } from './sync-workspace-from-dir'
810
import { get_checkpoint_path, sync_directory } from '../utils'
911
import { apply_git_diff } from '../utils/git-utils'
@@ -30,6 +32,18 @@ export const restore_checkpoint = async (params: {
3032
}
3133

3234
if (!params.options?.skip_confirmation) {
35+
const checkpoints = await get_checkpoints(params.context)
36+
if (
37+
checkpoints.length > 0 &&
38+
checkpoints[0].title != 'Before checkpoint restored'
39+
) {
40+
await create_checkpoint(
41+
params.workspace_provider,
42+
params.context,
43+
'Before checkpoint restored'
44+
)
45+
}
46+
3347
const old_temp_checkpoint = params.context.workspaceState.get<Checkpoint>(
3448
TEMPORARY_CHECKPOINT_STATE_KEY
3549
)

0 commit comments

Comments
 (0)