mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 12:04:04 +01:00
Add create new branch option (create worktree) (#259599)
* add create branch option on current branch * fix override
This commit is contained in:
@@ -3480,15 +3480,32 @@ export class CommandCenter {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check whether the selected branch is checked out in an existing worktree
|
||||
const worktree = repository.worktrees.find(worktree => worktree.ref === choice.refId);
|
||||
if (worktree) {
|
||||
const message = l10n.t('Branch "{0}" is already checked out in the worktree at "{1}".', choice.refName, worktree.path);
|
||||
await this.handleWorktreeConflict(worktree.path, message);
|
||||
return;
|
||||
}
|
||||
if (choice.refName === repository.HEAD?.name) {
|
||||
const message = l10n.t('Branch "{0}" is already checked out in the current repository.', choice.refName);
|
||||
const createBranch = l10n.t('Create New Branch');
|
||||
const pick = await window.showWarningMessage(message, { modal: true }, createBranch);
|
||||
|
||||
commitish = choice.refName;
|
||||
if (pick === createBranch) {
|
||||
branch = await this.promptForBranchName(repository);
|
||||
|
||||
if (!branch) {
|
||||
return;
|
||||
}
|
||||
|
||||
commitish = 'HEAD';
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Check whether the selected branch is checked out in an existing worktree
|
||||
const worktree = repository.worktrees.find(worktree => worktree.ref === choice.refId);
|
||||
if (worktree) {
|
||||
const message = l10n.t('Branch "{0}" is already checked out in the worktree at "{1}".', choice.refName, worktree.path);
|
||||
await this.handleWorktreeConflict(worktree.path, message);
|
||||
return;
|
||||
}
|
||||
commitish = choice.refName;
|
||||
}
|
||||
}
|
||||
|
||||
const worktreeName = ((branch ?? commitish).startsWith(branchPrefix)
|
||||
|
||||
Reference in New Issue
Block a user