Parcourir la source

Adds an overload for better perf optimization

main
Eric Amodio il y a 1 an
Parent
révision
bc99003bf5
2 fichiers modifiés avec 11 ajouts et 5 suppressions
  1. +3
    -1
      src/commands/ghpr/createWorktree.ts
  2. +8
    -4
      src/git/models/remote.ts

+ 3
- 1
src/commands/ghpr/createWorktree.ts Voir le fichier

@ -6,6 +6,7 @@ import { add as addRemote } from '../../git/actions/remote';
import { create as createWorktree } from '../../git/actions/worktree';
import { GitReference } from '../../git/models/reference';
import type { GitRemote } from '../../git/models/remote';
import { parseGitRemoteUrl } from '../../git/parsers/remoteParser';
import { Logger } from '../../logger';
import { command } from '../../system/command';
import { waitUntilNextTick } from '../../system/promise';
@ -79,9 +80,10 @@ export class CreateWorktreeCommand extends Command {
}
const remoteUrl = remoteUri.toString();
const [, remoteDomain, remotePath] = parseGitRemoteUrl(remoteUrl);
let remote: GitRemote | undefined;
[remote] = await repo.getRemotes({ filter: r => r.matches(remoteUrl) });
[remote] = await repo.getRemotes({ filter: r => r.matches(remoteDomain, remotePath) });
if (remote == null) {
const result = await window.showInformationMessage(
`Unable to find a remote for '${remoteUrl}'. Would you like to add a new remote?`,

+ 8
- 4
src/git/models/remote.ts Voir le fichier

@ -90,11 +90,15 @@ export class GitRemote
return this.provider?.hasRichIntegration() ?? false;
}
matches(url: string): boolean {
if (equalsIgnoreCase(url, this.url)) return true;
matches(url: string): boolean;
matches(domain: string, path: string): boolean;
matches(urlOrDomain: string, path?: string): boolean {
if (path == null) {
if (equalsIgnoreCase(urlOrDomain, this.url)) return true;
[, urlOrDomain, path] = parseGitRemoteUrl(urlOrDomain);
}
const [, domain, path] = parseGitRemoteUrl(url);
return equalsIgnoreCase(domain, this.domain) && equalsIgnoreCase(path, this.path);
return equalsIgnoreCase(urlOrDomain, this.domain) && equalsIgnoreCase(path, this.path);
}
async setAsDefault(value: boolean = true) {

Chargement…
Annuler
Enregistrer