Skip to content

Commit ccd1fc3

Browse files
committed
Prevent checkpoint creation for non-manual or temporary triggers when any workspace folder lacks git
- checkpoint should not be created automatically when not in git repository (as copying all files is very slow) └── apps └── editor └── src ├── commands │ ├── apply-response-command │ │ └── apply-response-command.ts │ ├── generate-commit-message-commands │ │ └── actions │ │ └── run-generate-action.ts │ └── history-command │ ├── actions │ │ ├── clear-all-checkpoints.ts │ │ ├── create-temporary-checkpoint.ts │ │ ├── delete-checkpoint-with-undo.ts │ │ ├── restore-checkpoint.ts │ │ ├── sync-workspace-from-dir.ts │ │ ├── toggle-checkpoint-pin.ts │ │ └── update-checkpoint-description.ts │ ├── history-command.ts │ ├── index.ts │ └── utils │ └── sync-directory.ts └── features └── checkpoints ├── actions │ ├── create-checkpoint.ts │ ├── delete-checkpoint.ts │ ├── get-checkpoints.ts │ └── index.ts ├── types │ ├── checkpoint.ts │ └── index.ts └── utils ├── copy-optimised-recursively.ts ├── get-checkpoint-path.ts ├── get-incremented-description.ts ├── git-utils.ts └── index.ts
1 parent b971752 commit ccd1fc3

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

‎apps/editor/src/commands/history-command/actions/create-temporary-checkpoint.ts‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,28 @@ import { Logger } from '@shared/utils/logger'
1515

1616
export const create_temporary_checkpoint = async (
1717
workspace_provider: WorkspaceProvider
18-
): Promise<Checkpoint> => {
18+
): Promise<Checkpoint | undefined> => {
19+
const workspace_folders = vscode.workspace.workspaceFolders
20+
21+
const folder_git_statuses = await Promise.all(
22+
workspace_folders.map((folder) => is_git_repository(folder))
23+
)
24+
25+
if (folder_git_statuses.some((has_git) => !has_git)) {
26+
return undefined
27+
}
28+
1929
await vscode.workspace.saveAll()
2030
const timestamp = Date.now()
2131
const checkpoint_dir_path = get_checkpoint_path(timestamp)
2232
const checkpoint_dir_uri = vscode.Uri.file(checkpoint_dir_path)
2333
await vscode.workspace.fs.createDirectory(checkpoint_dir_uri)
2434

25-
const workspace_folders = vscode.workspace.workspaceFolders!
2635
const git_data: Record<string, any> = {}
2736
let uses_git = false
2837

29-
for (const folder of workspace_folders) {
30-
const has_git = await is_git_repository(folder)
38+
for (const [index, folder] of workspace_folders.entries()) {
39+
const has_git = folder_git_statuses[index]
3140

3241
if (has_git) {
3342
uses_git = true

‎apps/editor/src/features/checkpoints/actions/create-checkpoint.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ export const create_checkpoint = async (params: {
7878
const folder_git_statuses = await Promise.all(
7979
workspace_folders.map((folder) => is_git_repository(folder))
8080
)
81+
82+
if (
83+
trigger != 'manual' &&
84+
folder_git_statuses.some((has_git) => !has_git)
85+
) {
86+
return undefined
87+
}
88+
8189
let new_checkpoint: Checkpoint | undefined
8290

8391
const create_checkpoint_task = async () => {

0 commit comments

Comments
 (0)