Skip to content

Commit 0998558

Browse files
Copilotalexr00
andcommitted
Address code review: static imports, error handling, documentation
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 48bde0a commit 0998558

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/github/folderRepositoryManager.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import { execFile } from 'child_process';
67
import * as nodePath from 'path';
8+
import { promisify } from 'util';
79
import { bulkhead } from 'cockatiel';
810
import * as vscode from 'vscode';
911
import { OctokitCommon } from './common';
@@ -2452,8 +2454,6 @@ export class FolderRepositoryManager extends Disposable {
24522454

24532455
async getWorktreeForBranch(branchName: string): Promise<string | undefined> {
24542456
try {
2455-
const { execFile } = await import('child_process');
2456-
const { promisify } = await import('util');
24572457
const execFileAsync = promisify(execFile);
24582458
const gitPath = vscode.workspace.getConfiguration('git').get<string>('path') || 'git';
24592459
const { stdout } = await execFileAsync(gitPath, ['worktree', 'list', '--porcelain'], {
@@ -2492,13 +2492,16 @@ export class FolderRepositoryManager extends Disposable {
24922492
}
24932493

24942494
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+
}
25022505
}
25032506

25042507
async fetchAndCheckout(pullRequest: PullRequestModel, progress: vscode.Progress<{ message?: string; increment?: number }>): Promise<void> {

src/github/pullRequestReviewCommon.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ export namespace PullRequestReviewCommon {
290290

291291
interface SelectedAction {
292292
type: 'remoteHead' | 'local' | 'remote' | 'suspend' | 'worktree'
293+
/** Path to the worktree directory to remove. Only used when type is 'worktree'. */
293294
worktreePath?: string;
294295
};
295296

0 commit comments

Comments
 (0)