Skip to content

Commit 15fe3b3

Browse files
committed
feat(core): add repository selection for worktree prune
- Add repository selection prompt for prune worktree command - Update add worktree command to use a more specific prompt - Localize new prompts in Japanese, Chinese (Simplified and Traditional) - Refactor pruneWorktree function to handle both dry run and actual pruning
1 parent 4c14dc4 commit 15fe3b3

File tree

7 files changed

+14
-9
lines changed

7 files changed

+14
-9
lines changed

l10n/bundle.l10n.ja.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,6 @@
133133
"Bundling repo..., {path}": "リポジトリをバンドル中..., {path}",
134134
"Repository backup successful: {path}": "リポジトリのバックアップに成功しました: {path}",
135135
"The selected Git repository paths will be removed from the list": "選択された Git リポジトリのパスはリストから削除されます",
136-
"Please select the Git repository paths you want to remove": "削除したい Git リポジトリのパスを選択してください"
136+
"Please select the Git repository paths you want to remove": "削除したい Git リポジトリのパスを選択してください",
137+
"Select git repository for prune worktree": "ワークツリーを整理するGitリポジトリを選択してください"
137138
}

l10n/bundle.l10n.zh-cn.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,6 @@
133133
"Bundling repo..., {path}": "打包仓库中..., {path}",
134134
"Repository backup successful: {path}": "仓库备份成功: {path}",
135135
"The selected Git repository paths will be removed from the list": "选中的 Git 仓库路径将从列表中移除",
136-
"Please select the Git repository paths you want to remove": "请选择需要移除的 Git 仓库路径"
136+
"Please select the Git repository paths you want to remove": "请选择需要移除的 Git 仓库路径",
137+
"Select git repository for prune worktree": "请选择需要清理 worktree 的 git 仓库"
137138
}

l10n/bundle.l10n.zh-tw.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,6 @@
133133
"Bundling repo..., {path}": "組合儲存庫..., {path}",
134134
"Repository backup successful: {path}": "儲存庫備份成功: {path}",
135135
"The selected Git repository paths will be removed from the list": "選取的 Git 儲存庫路徑將從清單中移除",
136-
"Please select the Git repository paths you want to remove": "請選擇要移除的 Git 儲存庫路徑"
136+
"Please select the Git repository paths you want to remove": "請選擇要移除的 Git 儲存庫路徑",
137+
"Select git repository for prune worktree": "請選擇需要清理 worktree 的 git 儲存庫"
137138
}

src/core/command/addWorktreeCmd.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const pickBranchItem = async (dir: string, mainFolder: string) => {
2121
};
2222

2323
export const addWorktreeCmd = async (item?: IWorktreeLess) => {
24-
let gitFolder = item?.path || (await pickGitFolder());
24+
let gitFolder = item?.path || (await pickGitFolder(vscode.l10n.t('Select git repository for create worktree')));
2525
if (gitFolder === null) Alert.showErrorMessage(vscode.l10n.t('Please open a git repository in workspace'));
2626
if (!gitFolder) return false;
2727
const mainFolder = await getMainFolder(gitFolder);

src/core/command/pruneWorktreeCmd.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import * as vscode from 'vscode';
22
import { pruneWorktree } from '@/core/git/pruneWorktree';
33
import { Alert } from '@/core/ui/message';
44
import logger from '@/core/log/logger';
5+
import { pickGitFolder } from '@/core/ui/pickGitFolder';
56

67
export const pruneWorktreeCmd = async () => {
78
try {
8-
let output = await pruneWorktree(true);
9+
const repoPath = await pickGitFolder(vscode.l10n.t('Select git repository for prune worktree')) || '';
10+
let output = await pruneWorktree(true, repoPath);
911
if (!output?.length) {
1012
return;
1113
}
@@ -21,7 +23,7 @@ export const pruneWorktreeCmd = async () => {
2123
if (confirm !== ok) {
2224
return;
2325
}
24-
await pruneWorktree();
26+
await pruneWorktree(false, repoPath);
2527
Alert.showInformationMessage(vscode.l10n.t('Prune worktree succeeded'));
2628
} catch (error) {
2729
Alert.showErrorMessage(vscode.l10n.t('Failed to prune worktree'));

src/core/git/pruneWorktree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export async function analyzePruneDryRun(
5454
return results;
5555
}
5656

57-
export async function pruneWorktree(dryRun: boolean = false, cwd?: string) {
57+
export async function pruneWorktree(dryRun: boolean, cwd: string) {
5858
try {
5959
const res = await execAuto(
6060
cwd,

src/core/ui/pickGitFolder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { WorkspaceState } from '@/core/state';
33
import path from 'path';
44
import { withResolvers } from '@/core/util/promise';
55

6-
export const pickGitFolder = async (): Promise<string | undefined | null> => {
6+
export const pickGitFolder = async (title: string): Promise<string | undefined | null> => {
77
const mainFolders = WorkspaceState.get('mainFolders', []).map((i) => i.path);
88
if (mainFolders.length === 0) return null;
99
if (mainFolders.length > 1) {
@@ -17,7 +17,7 @@ export const pickGitFolder = async (): Promise<string | undefined | null> => {
1717
}),
1818
];
1919
const folderPath = await vscode.window.showQuickPick(items, {
20-
title: vscode.l10n.t('Select git repository for create worktree'),
20+
title,
2121
canPickMany: false,
2222
});
2323
return folderPath?.description;

0 commit comments

Comments
 (0)