From be5afb7c6db6eb7157a4ff65379caa17329951c4 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Mon, 30 Oct 2017 15:53:16 -0400 Subject: [PATCH] Fixes #183 - group same domain/path into same remote --- src/git/models/remote.ts | 8 +++++++- src/git/parsers/remoteParser.ts | 9 +++++---- src/views/remoteNode.ts | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/git/models/remote.ts b/src/git/models/remote.ts index 03fb772..03376b4 100644 --- a/src/git/models/remote.ts +++ b/src/git/models/remote.ts @@ -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); } } \ No newline at end of file diff --git a/src/git/parsers/remoteParser.ts b/src/git/parsers/remoteParser.ts index 2b91da8..45b5fcc 100644 --- a/src/git/parsers/remoteParser.ts +++ b/src/git/parsers/remoteParser.ts @@ -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); diff --git a/src/views/remoteNode.ts b/src/views/remoteNode.ts index aab0cb0..11fc5bb 100644 --- a/src/views/remoteNode.ts +++ b/src/views/remoteNode.ts @@ -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) {