Skip to content

Commit 8bef53d

Browse files
refine default worktree name (microsoft#257501)
1 parent 91a664f commit 8bef53d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

extensions/git/src/commands.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3398,6 +3398,7 @@ export class CommandCenter {
33983398

33993399
private async _createWorktree(repository: Repository, worktreePath?: string, name?: string, newBranch?: boolean): Promise<void> {
34003400
const config = workspace.getConfiguration('git');
3401+
const branchPrefix = config.get<string>('branchPrefix')!;
34013402
const showRefDetails = config.get<boolean>('showReferenceDetails') === true;
34023403

34033404
if (!name) {
@@ -3425,7 +3426,7 @@ export class CommandCenter {
34253426

34263427
newBranch = true;
34273428
name = branchName;
3428-
} else if (choice instanceof BranchItem && choice.refName) {
3429+
} else if (choice instanceof RefItem && choice.refName) {
34293430
name = choice.refName;
34303431
} else {
34313432
return;
@@ -3434,9 +3435,10 @@ export class CommandCenter {
34343435

34353436
const disposables: Disposable[] = [];
34363437
const inputBox = window.createInputBox();
3438+
34373439
inputBox.placeholder = l10n.t('Worktree name');
34383440
inputBox.prompt = l10n.t('Please provide a worktree name');
3439-
inputBox.value = name || '';
3441+
inputBox.value = name.startsWith(branchPrefix) ? name.substring(branchPrefix.length) : name;
34403442
inputBox.show();
34413443

34423444
const worktreeName = await new Promise<string | undefined>((resolve) => {

0 commit comments

Comments
 (0)