diff --git a/src/commands/git/worktree.ts b/src/commands/git/worktree.ts index 6a412b31121aa..f1b5850230de5 100644 --- a/src/commands/git/worktree.ts +++ b/src/commands/git/worktree.ts @@ -524,7 +524,7 @@ export class WorktreeGitCommand extends QuickCommand { if (state.addRemote != null) { await state.repo.git .remotes() - .addRemoteWithResult?.(state.addRemote.name, state.addRemote.url, { fetch: true }); + .addRemote?.(state.addRemote.name, state.addRemote.url, { fetch: true }); } worktree = await state.repo.git.worktrees()?.createWorktreeWithResult(uri.fsPath, { diff --git a/src/uris/deepLinks/deepLinkService.ts b/src/uris/deepLinks/deepLinkService.ts index dddf994a63e03..593b17d806b58 100644 --- a/src/uris/deepLinks/deepLinkService.ts +++ b/src/uris/deepLinks/deepLinkService.ts @@ -924,21 +924,19 @@ export class DeepLinkService implements Disposable { if (remoteName) { try { - await repo.git.remotes().addRemoteWithResult?.(remoteName, remoteUrl, { fetch: true }); + this._context.remote = await repo.git + .remotes() + .addRemoteWithResult?.(remoteName, remoteUrl, { fetch: true }); + if (!this._context.remote) { + action = DeepLinkServiceAction.DeepLinkErrored; + message = 'Failed to add remote.'; + break; + } } catch { action = DeepLinkServiceAction.DeepLinkErrored; message = 'Failed to add remote.'; break; } - - [this._context.remote] = await repo.git - .remotes() - .getRemotes({ filter: r => r.url === remoteUrl }); - if (!this._context.remote) { - action = DeepLinkServiceAction.DeepLinkErrored; - message = 'Failed to add remote.'; - break; - } } else { action = DeepLinkServiceAction.DeepLinkCancelled; break; @@ -953,23 +951,19 @@ export class DeepLinkService implements Disposable { if (secondaryRemoteName) { try { - await repo.git + this._context.secondaryRemote = await repo.git .remotes() .addRemoteWithResult?.(secondaryRemoteName, secondaryRemoteUrl, { fetch: true }); + if (!this._context.secondaryRemote) { + action = DeepLinkServiceAction.DeepLinkErrored; + message = 'Failed to add remote.'; + break; + } } catch { action = DeepLinkServiceAction.DeepLinkErrored; message = 'Failed to add remote.'; break; } - - [this._context.secondaryRemote] = await repo.git.remotes().getRemotes({ - filter: r => r.url === secondaryRemoteUrl, - }); - if (!this._context.secondaryRemote) { - action = DeepLinkServiceAction.DeepLinkErrored; - message = 'Failed to add remote.'; - break; - } } else { action = DeepLinkServiceAction.DeepLinkCancelled; break;