Add create new branch option (create worktree) (#259599)

* add create branch option on current branch

* fix override
This commit is contained in:
Christy 😺
2025-08-04 11:28:27 -07:00
committed by GitHub
parent 59c3f0b8cb
commit cb1290bcb1

View File

@@ -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)