Eric Amodio před 1 rokem
rodič
revize
bb6bce0783
3 změnil soubory, kde provedl 41 přidání a 21 odebrání
  1. +1
    -0
      CHANGELOG.md
  2. +10
    -2
      src/git/models/remote.ts
  3. +30
    -19
      src/git/parsers/remoteParser.ts

+ 1
- 0
CHANGELOG.md Zobrazit soubor

@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Changes _Compact Graph Column Layout_ context menu command to _Use Compact Graph Column_ for better clarity
- Changes _Default Graph Column Layout_ context menu command to _Use Expanded Graph Column_ for better clarity
- Improves remote parsing for better integration support for some edge cases
## [14.1.1] - 2023-07-18

+ 10
- 2
src/git/models/remote.ts Zobrazit soubor

@ -54,13 +54,21 @@ export class GitRemote
);
}
get domain() {
return this.provider?.domain ?? this._domain;
}
get path() {
return this.provider?.path ?? this._path;
}
constructor(
public readonly repoPath: string,
public readonly id: string,
public readonly name: string,
public readonly scheme: string,
public readonly domain: string,
public readonly path: string,
private readonly _domain: string,
private readonly _path: string,
public readonly provider: TProvider,
public readonly urls: { type: GitRemoteType; url: string }[],
) {}

+ 30
- 19
src/git/parsers/remoteParser.ts Zobrazit soubor

@ -17,8 +17,7 @@ export class GitRemoteParser {
): GitRemote[] | undefined {
if (!data) return undefined;
const remotes: GitRemote[] = [];
const groups = Object.create(null) as Record<string, GitRemote | undefined>;
const remotes = new Map<string, GitRemote>();
let name;
let url;
@ -28,7 +27,6 @@ export class GitRemoteParser {
let domain;
let path;
let uniqueness;
let remote: GitRemote | undefined;
let match;
@ -39,36 +37,49 @@ export class GitRemoteParser {
[, name, url, type] = match;
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
name = ` ${name}`.substr(1);
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
url = ` ${url}`.substr(1);
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
type = ` ${type}`.substr(1);
[scheme, domain, path] = parseGitRemoteUrl(url);
uniqueness = `${domain ? `${domain}/` : ''}${path}`;
remote = groups[uniqueness];
if (remote === undefined) {
remote = remotes.get(name);
if (remote == null) {
remote = new GitRemote(
repoPath,
`${domain ? `${domain}/` : ''}${path}`,
name,
scheme,
domain,
path,
remoteProviderMatcher(url, domain, path),
[{ url: url, type: type as GitRemoteType }],
);
remotes.set(name, remote);
} else {
remote.urls.push({ url: url, type: type as GitRemoteType });
if (remote.provider != null && type !== 'push') continue;
const provider = remoteProviderMatcher(url, domain, path);
if (provider == null) continue;
remote = new GitRemote(
repoPath,
uniqueness,
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
` ${name}`.substr(1),
`${domain ? `${domain}/` : ''}${path}`,
name,
scheme,
provider !== undefined ? provider.domain : domain,
provider !== undefined ? provider.path : path,
domain,
path,
provider,
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
[{ url: url, type: ` ${type}`.substr(1) as GitRemoteType }],
remote.urls,
);
remotes.push(remote);
groups[uniqueness] = remote;
} else {
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
remote.urls.push({ url: url, type: ` ${type}`.substr(1) as GitRemoteType });
remotes.set(name, remote);
}
} while (true);
return remotes;
return [...remotes.values()];
}
}

Načítá se…
Zrušit
Uložit