瀏覽代碼

Adds an overload for better perf optimization

main
Eric Amodio 1 年之前
父節點
當前提交
bc99003bf5
共有 2 個文件被更改,包括 11 次插入5 次删除
  1. +3
    -1
      src/commands/ghpr/createWorktree.ts
  2. +8
    -4
      src/git/models/remote.ts

+ 3
- 1
src/commands/ghpr/createWorktree.ts 查看文件

@ -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 查看文件

@ -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) {

Loading…
取消
儲存