mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-23 03:39:23 +00:00
Git: Fix worktree checkout default actions (#262414)
* fix worktree checkout default action * remove comments * clean up * fix returns * change action to 'cancel'
This commit is contained in:
@@ -2938,7 +2938,25 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
if (err.gitErrorCode === GitErrorCodes.WorktreeBranchAlreadyUsed) {
|
||||
this.handleWorktreeBranchAlreadyUsed(err);
|
||||
// Not checking out in a worktree (use standard error handling)
|
||||
if (!repository.dotGit.commonPath) {
|
||||
await this.handleWorktreeBranchAlreadyUsed(err);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check out in a worktree (check if worktree's main repository is open in workspace and if branch is already checked out in main repository)
|
||||
const commonPath = path.dirname(repository.dotGit.commonPath);
|
||||
if (workspace.workspaceFolders && workspace.workspaceFolders.some(folder => pathEquals(folder.uri.fsPath, commonPath))) {
|
||||
const mainRepository = this.model.getRepository(commonPath);
|
||||
if (mainRepository && item.refName && item.refName.replace(`${item.refRemote}/`, '') === mainRepository.HEAD?.name) {
|
||||
const message = l10n.t('Branch "{0}" is already checked out in the current window.', item.refName);
|
||||
await window.showErrorMessage(message, { modal: true });
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check out in a worktree, (branch is already checked out in existing worktree)
|
||||
await this.handleWorktreeBranchAlreadyUsed(err);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3744,7 +3762,6 @@ export class CommandCenter {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@command('git.deleteWorktree', { repository: true, repositoryFilter: ['worktree'] })
|
||||
async deleteWorktree(repository: Repository): Promise<void> {
|
||||
if (!repository.dotGit.commonPath) {
|
||||
|
||||
Reference in New Issue
Block a user