From 4083eeefc1bdf2aa7b1e8a11b973b68c10f8a6df Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Mon, 7 Aug 2023 11:34:17 -0700 Subject: [PATCH] Preserve ref in desktop remote -> local clone (#189852) --- extensions/git/src/commands.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 8eba9cbac03..af40853e27e 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -749,20 +749,26 @@ export class CommandCenter { const ref = selection.repository.HEAD?.upstream?.name; if (uri !== undefined) { - // Launch desktop client if currently in web let target = `${env.uriScheme}://vscode.git/clone?url=${encodeURIComponent(uri)}`; - if (env.uiKind === UIKind.Web) { + const isWeb = env.uiKind === UIKind.Web; + const isRemote = env.remoteName !== undefined; + + if (isWeb || isRemote) { if (ref !== undefined) { target += `&ref=${encodeURIComponent(ref)}`; } - return Uri.parse(target); - } - // If already in desktop client but in a remote window, we need to force a new window - // so that the git extension can access the local filesystem for cloning - if (env.remoteName !== undefined) { - target += `&windowId=_blank`; - return Uri.parse(target); + if (isWeb) { + // Launch desktop client if currently in web + return Uri.parse(target); + } + + if (isRemote) { + // If already in desktop client but in a remote window, we need to force a new window + // so that the git extension can access the local filesystem for cloning + target += `&windowId=_blank`; + return Uri.parse(target); + } } // Otherwise, directly clone