Skip to content

Commit 5abb804

Browse files
committed
Avoids extra lookup
1 parent 600c7dd commit 5abb804

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

src/commands/git/worktree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ export class WorktreeGitCommand extends QuickCommand<State> {
524524
if (state.addRemote != null) {
525525
await state.repo.git
526526
.remotes()
527-
.addRemoteWithResult?.(state.addRemote.name, state.addRemote.url, { fetch: true });
527+
.addRemote?.(state.addRemote.name, state.addRemote.url, { fetch: true });
528528
}
529529

530530
worktree = await state.repo.git.worktrees()?.createWorktreeWithResult(uri.fsPath, {

src/uris/deepLinks/deepLinkService.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -924,21 +924,19 @@ export class DeepLinkService implements Disposable {
924924

925925
if (remoteName) {
926926
try {
927-
await repo.git.remotes().addRemoteWithResult?.(remoteName, remoteUrl, { fetch: true });
927+
this._context.remote = await repo.git
928+
.remotes()
929+
.addRemoteWithResult?.(remoteName, remoteUrl, { fetch: true });
930+
if (!this._context.remote) {
931+
action = DeepLinkServiceAction.DeepLinkErrored;
932+
message = 'Failed to add remote.';
933+
break;
934+
}
928935
} catch {
929936
action = DeepLinkServiceAction.DeepLinkErrored;
930937
message = 'Failed to add remote.';
931938
break;
932939
}
933-
934-
[this._context.remote] = await repo.git
935-
.remotes()
936-
.getRemotes({ filter: r => r.url === remoteUrl });
937-
if (!this._context.remote) {
938-
action = DeepLinkServiceAction.DeepLinkErrored;
939-
message = 'Failed to add remote.';
940-
break;
941-
}
942940
} else {
943941
action = DeepLinkServiceAction.DeepLinkCancelled;
944942
break;
@@ -953,23 +951,19 @@ export class DeepLinkService implements Disposable {
953951

954952
if (secondaryRemoteName) {
955953
try {
956-
await repo.git
954+
this._context.secondaryRemote = await repo.git
957955
.remotes()
958956
.addRemoteWithResult?.(secondaryRemoteName, secondaryRemoteUrl, { fetch: true });
957+
if (!this._context.secondaryRemote) {
958+
action = DeepLinkServiceAction.DeepLinkErrored;
959+
message = 'Failed to add remote.';
960+
break;
961+
}
959962
} catch {
960963
action = DeepLinkServiceAction.DeepLinkErrored;
961964
message = 'Failed to add remote.';
962965
break;
963966
}
964-
965-
[this._context.secondaryRemote] = await repo.git.remotes().getRemotes({
966-
filter: r => r.url === secondaryRemoteUrl,
967-
});
968-
if (!this._context.secondaryRemote) {
969-
action = DeepLinkServiceAction.DeepLinkErrored;
970-
message = 'Failed to add remote.';
971-
break;
972-
}
973967
} else {
974968
action = DeepLinkServiceAction.DeepLinkCancelled;
975969
break;

0 commit comments

Comments
 (0)