Browse Source

Fixes #183 - group same domain/path into same remote

main
Eric Amodio 7 years ago
parent
commit
be5afb7c6d
3 changed files with 14 additions and 7 deletions
  1. +7
    -1
      src/git/models/remote.ts
  2. +5
    -4
      src/git/parsers/remoteParser.ts
  3. +2
    -2
      src/views/remoteNode.ts

+ 7
- 1
src/git/models/remote.ts View File

@ -10,7 +10,13 @@ export class GitRemote {
provider?: RemoteProvider;
constructor(public readonly repoPath: string, public readonly name: string, public readonly url: string, public readonly domain: string, public readonly path: string, public readonly types: GitRemoteType[]) {
constructor(
public readonly repoPath: string,
public readonly name: string,
public readonly domain: string,
public readonly path: string,
public readonly types: { type: GitRemoteType, url: string }[]
) {
this.provider = RemoteProviderFactory.getRemoteProvider(this.domain, this.path);
}
}

+ 5
- 4
src/git/parsers/remoteParser.ts View File

@ -22,14 +22,15 @@ export class GitRemoteParser {
const [domain, path] = this.parseGitUrl(url);
let remote: GitRemote | undefined = groups[url];
const uniqueness = `${domain}/${path}`;
let remote: GitRemote | undefined = groups[uniqueness];
if (remote === undefined) {
remote = new GitRemote(repoPath, match[1], url, domain, path, [match[3] as GitRemoteType]);
remote = new GitRemote(repoPath, match[1], domain, path, [{ url: url, type: match[3] as GitRemoteType }]);
remotes.push(remote);
groups[url] = remote;
groups[uniqueness] = remote;
}
else {
remote.types.push(match[3] as GitRemoteType);
remote.types.push({ url: url, type: match[3] as GitRemoteType });
}
} while (match != null);

+ 2
- 2
src/views/remoteNode.ts View File

@ -28,8 +28,8 @@ export class RemoteNode extends ExplorerNode {
}
getTreeItem(): TreeItem {
const fetch = this.remote.types.includes(GitRemoteType.Push);
const push = this.remote.types.includes(GitRemoteType.Push);
const fetch = this.remote.types.find(rt => rt.type === GitRemoteType.Fetch);
const push = this.remote.types.find(rt => rt.type === GitRemoteType.Push);
let separator;
if (fetch && push) {

Loading…
Cancel
Save