|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information. |
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
| 6 | +import { execFile } from 'child_process'; |
6 | 7 | import * as nodePath from 'path'; |
| 8 | +import { promisify } from 'util'; |
7 | 9 | import { bulkhead } from 'cockatiel'; |
8 | 10 | import * as vscode from 'vscode'; |
9 | 11 | import { OctokitCommon } from './common'; |
@@ -2452,8 +2454,6 @@ export class FolderRepositoryManager extends Disposable { |
2452 | 2454 |
|
2453 | 2455 | async getWorktreeForBranch(branchName: string): Promise<string | undefined> { |
2454 | 2456 | try { |
2455 | | - const { execFile } = await import('child_process'); |
2456 | | - const { promisify } = await import('util'); |
2457 | 2457 | const execFileAsync = promisify(execFile); |
2458 | 2458 | const gitPath = vscode.workspace.getConfiguration('git').get<string>('path') || 'git'; |
2459 | 2459 | const { stdout } = await execFileAsync(gitPath, ['worktree', 'list', '--porcelain'], { |
@@ -2492,13 +2492,16 @@ export class FolderRepositoryManager extends Disposable { |
2492 | 2492 | } |
2493 | 2493 |
|
2494 | 2494 | async removeWorktree(worktreePath: string): Promise<void> { |
2495 | | - const { execFile } = await import('child_process'); |
2496 | | - const { promisify } = await import('util'); |
2497 | | - const execFileAsync = promisify(execFile); |
2498 | | - const gitPath = vscode.workspace.getConfiguration('git').get<string>('path') || 'git'; |
2499 | | - await execFileAsync(gitPath, ['worktree', 'remove', worktreePath], { |
2500 | | - cwd: this.repository.rootUri.fsPath, |
2501 | | - }); |
| 2495 | + try { |
| 2496 | + const execFileAsync = promisify(execFile); |
| 2497 | + const gitPath = vscode.workspace.getConfiguration('git').get<string>('path') || 'git'; |
| 2498 | + await execFileAsync(gitPath, ['worktree', 'remove', worktreePath], { |
| 2499 | + cwd: this.repository.rootUri.fsPath, |
| 2500 | + }); |
| 2501 | + } catch (e) { |
| 2502 | + Logger.error(`Failed to remove worktree ${worktreePath}: ${e}`, this.id); |
| 2503 | + throw e; |
| 2504 | + } |
2502 | 2505 | } |
2503 | 2506 |
|
2504 | 2507 | async fetchAndCheckout(pullRequest: PullRequestModel, progress: vscode.Progress<{ message?: string; increment?: number }>): Promise<void> { |
|
0 commit comments