Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit f615190

Browse files
committed
Merge pull request #32 from github/shana/list-git-repos
Add list of repos to the connect page
2 parents e1bc0fa + d240141 commit f615190

37 files changed

+996
-128
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using GitHub.Models;
2+
using GitHub.VisualStudio;
3+
using Microsoft.VisualStudio.TeamFoundation.Git.Extensibility;
4+
using NullGuard;
5+
6+
namespace GitHub.Extensions
7+
{
8+
public static class RepositoryModelExtensions
9+
{
10+
/// <summary>
11+
/// Create a SimpleRepositoryModel from a VS git repo object
12+
/// </summary>
13+
[return:AllowNull]
14+
public static ISimpleRepositoryModel ToModel([AllowNull] this IGitRepositoryInfo repo)
15+
{
16+
if (repo == null)
17+
return null;
18+
var uri = repo.GetUriFromRepository();
19+
var name = uri?.NameWithOwner;
20+
return name != null ? new SimpleRepositoryModel(name, uri, repo.RepositoryPath) : null;
21+
}
22+
}
23+
}

src/GitHub.App/GitHub.App.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
<HintPath>..\..\lib\Microsoft.TeamFoundation.Git.Controls.dll</HintPath>
5959
<Private>False</Private>
6060
</Reference>
61+
<Reference Include="Microsoft.TeamFoundation.Git.Provider, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
62+
<HintPath>..\..\lib\Microsoft.TeamFoundation.Git.Provider.dll</HintPath>
63+
<Private>False</Private>
64+
</Reference>
6165
<Reference Include="Microsoft.VisualStudio.ComponentModelHost, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
6266
<Reference Include="Microsoft.VisualStudio.Shell.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
6367
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0" />
@@ -122,6 +126,7 @@
122126
<Compile Include="Caches\ImageCache.cs" />
123127
<Compile Include="Extensions\AkavacheExtensions.cs" />
124128
<Compile Include="Extensions\EnvironmentExtensions.cs" />
129+
<Compile Include="Extensions\RepositoryModelExtensions.cs" />
125130
<Compile Include="Extensions\ValidationExtensions.cs" />
126131
<Compile Include="Infrastructure\LoggingConfiguration.cs" />
127132
<Compile Include="Services\AvatarProvider.cs" />

src/GitHub.App/Models/RepositoryHosts.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public RepositoryHosts(
5252
})
5353
.WhereNotNull()
5454
.Select(HostAddress.Create)
55-
.Where(x => connectionManager.Connections.Any(c => c.HostAddress == x))
55+
.Where(x => connectionManager.Connections.Any(c => c.HostAddress.Equals(x)))
5656
.Select(repositoryHostFactory.Create)
5757
.Do(x => EnterpriseHost = x)
5858
.Do(disposables.Add)
Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,47 @@
11
using GitHub.Primitives;
2-
using GitHub.UI;
2+
using NullGuard;
3+
using System;
4+
using System.Globalization;
35

46
namespace GitHub.Models
57
{
6-
public class RepositoryModel : IRepositoryModel
8+
public class RepositoryModel : SimpleRepositoryModel, IRepositoryModel, IEquatable<RepositoryModel>
79
{
8-
public RepositoryModel(string name, string cloneUrl, bool isPrivate, bool isFork, IAccount ownerAccount)
10+
public RepositoryModel(string name, UriString cloneUrl, bool isPrivate, bool isFork, IAccount ownerAccount)
11+
: base(name, cloneUrl)
912
{
10-
Name = name;
1113
Owner = ownerAccount;
12-
CloneUrl = cloneUrl;
13-
Icon = isPrivate
14-
? Octicon.@lock
15-
: isFork
16-
? Octicon.repo_forked
17-
: Octicon.repo;
14+
SetIcon(isPrivate, isFork);
1815
}
1916

20-
public string Name { get; private set; }
21-
2217
public IAccount Owner { get; private set; }
18+
public override int GetHashCode()
19+
{
20+
return (Owner?.GetHashCode() ?? 0) ^ base.GetHashCode();
21+
}
22+
23+
public override bool Equals([AllowNull]object obj)
24+
{
25+
if (ReferenceEquals(this, obj))
26+
return true;
27+
var other = obj as RepositoryModel;
28+
return other != null && Equals(Owner, other.Owner) && base.Equals(obj);
29+
}
2330

24-
public UriString CloneUrl { get; private set; }
31+
bool IEquatable<RepositoryModel>.Equals([AllowNull]RepositoryModel other)
32+
{
33+
if (ReferenceEquals(this, other))
34+
return true;
35+
return other != null && Equals(Owner, other.Owner) && base.Equals(other as SimpleRepositoryModel);
36+
}
2537

26-
public Octicon Icon { get; private set; }
38+
internal string DebuggerDisplay
39+
{
40+
get
41+
{
42+
return String.Format(CultureInfo.InvariantCulture,
43+
"{4}\tName: {0} CloneUrl: {1} LocalPath: {2} Account: {3}", Name, CloneUrl, LocalPath, Owner, GetHashCode());
44+
}
45+
}
2746
}
2847
}

src/GitHub.App/SampleData/SampleViewModels.cs

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
using GitHub.ViewModels;
1616
using GitHub.VisualStudio.TeamExplorer.Home;
1717
using ReactiveUI;
18+
using GitHub.VisualStudio.TeamExplorer.Connect;
19+
using System.Collections.ObjectModel;
1820

1921
namespace GitHub.SampleData
2022
{
@@ -199,6 +201,7 @@ class Conn : IConnection
199201
public HostAddress HostAddress { get; set; }
200202

201203
public string Username { get; set; }
204+
public ObservableCollection<ISimpleRepositoryModel> Repositories { get; set; }
202205

203206
public IObservable<IConnection> Login()
204207
{
@@ -208,6 +211,10 @@ public IObservable<IConnection> Login()
208211
public void Logout()
209212
{
210213
}
214+
215+
public void Dispose()
216+
{
217+
}
211218
}
212219

213220
public RepositoryPublishViewModelDesigner()
@@ -398,12 +405,16 @@ public RepositoryModelDesigner(string name, string owner)
398405
Owner = new AccountDesigner { Login = owner };
399406
}
400407

408+
public void SetIcon(bool isPrivate, bool isFork)
409+
{
410+
}
411+
412+
public string Name { get; set; }
401413
public UriString CloneUrl { get; set; }
414+
public string LocalPath { get; set; }
402415

403416
public Octicon Icon { get; set; }
404417

405-
public string Name { get; set; }
406-
407418
public IAccount Owner { get; set; }
408419
}
409420

@@ -530,4 +541,46 @@ public string RepoUrl
530541
set;
531542
}
532543
}
544+
545+
public class GitHubConnectSectionDesigner : IGitHubConnectSection
546+
{
547+
public GitHubConnectSectionDesigner()
548+
{
549+
Repositories = new ObservableCollection<ISimpleRepositoryModel>();
550+
Repositories.Add(new SimpleRepositoryModel("octokit", new UriString("https://github.com/octokit/octokit.net"), @"C:\Users\user\Source\Repos\octokit.net"));
551+
Repositories.Add(new SimpleRepositoryModel("cefsharp", new UriString("https://github.com/cefsharp/cefsharp"), @"C:\Users\user\Source\Repos\cefsharp"));
552+
Repositories.Add(new SimpleRepositoryModel("git-lfs", new UriString("https://github.com/github/git-lfs"), @"C:\Users\user\Source\Repos\git-lfs"));
553+
Repositories.Add(new SimpleRepositoryModel("another octokit", new UriString("https://github.com/octokit/octokit.net"), @"C:\Users\user\Source\Repos\another-octokit.net"));
554+
Repositories.Add(new SimpleRepositoryModel("some cefsharp", new UriString("https://github.com/cefsharp/cefsharp"), @"C:\Users\user\Source\Repos\something-else"));
555+
Repositories.Add(new SimpleRepositoryModel("even more git-lfs", new UriString("https://github.com/github/git-lfs"), @"C:\Users\user\Source\Repos\A different path"));
556+
}
557+
558+
public ObservableCollection<ISimpleRepositoryModel> Repositories
559+
{
560+
get; set;
561+
}
562+
563+
public void DoClone()
564+
{
565+
}
566+
567+
public void DoCreate()
568+
{
569+
}
570+
571+
public void SignOut()
572+
{
573+
}
574+
575+
public void Login()
576+
{
577+
}
578+
579+
public bool OpenRepository()
580+
{
581+
return true;
582+
}
583+
584+
public IConnection SectionConnection { get; }
585+
}
533586
}

src/GitHub.App/Services/ModelService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using NLog;
1515
using NullGuard;
1616
using Octokit;
17+
using GitHub.Primitives;
1718

1819
namespace GitHub.Services
1920
{
@@ -216,7 +217,7 @@ IRepositoryModel Create(RepositoryCacheItem repositoryCacheItem)
216217
{
217218
return new RepositoryModel(
218219
repositoryCacheItem.Name,
219-
repositoryCacheItem.CloneUrl,
220+
new UriString(repositoryCacheItem.CloneUrl),
220221
repositoryCacheItem.Private,
221222
repositoryCacheItem.Fork,
222223
Create(repositoryCacheItem.Owner));

src/GitHub.Exports/GitHub.Exports.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@
8484
<Reference Include="System" />
8585
<Reference Include="System.ComponentModel.Composition" />
8686
<Reference Include="System.Core" />
87+
<Reference Include="System.Management" />
88+
<Reference Include="System.Management.Instrumentation" />
8789
<Reference Include="System.Net.Http" />
8890
<Reference Include="System.Xaml" />
8991
<Reference Include="System.Xml.Linq" />
@@ -97,12 +99,18 @@
9799
<None Include="..\..\script\Key.snk" Condition="$(Buildtype) == 'Internal'">
98100
<Link>Key.snk</Link>
99101
</None>
102+
<Compile Include="Helpers\INotifyPropertySource.cs" />
103+
<Compile Include="Helpers\PropertyNotifierExtensions.cs" />
100104
<Compile Include="Info\ApplicationInfo.cs" />
101105
<Compile Include="Models\IAccount.cs" />
102106
<Compile Include="Models\IConnectionManager.cs" />
103107
<Compile Include="Models\IExportFactoryProvider.cs" />
108+
<Compile Include="Models\ISimpleRepositoryModel.cs" />
109+
<Compile Include="Models\SimpleRepositoryModel.cs" />
110+
<Compile Include="Helpers\NotificationAwareObject.cs" />
104111
<Compile Include="Services\Connection.cs" />
105112
<Compile Include="Services\ITeamExplorerServiceHolder.cs" />
113+
<Compile Include="Services\Logger.cs" />
106114
<Compile Include="Services\Services.cs" />
107115
<Compile Include="Services\VSServices.cs" />
108116
<Compile Include="Models\IConnection.cs" />
@@ -116,6 +124,7 @@
116124
<Compile Include="Services\VSExtensions.cs" />
117125
<Compile Include="UI\IView.cs" />
118126
<Compile Include="UI\Octicon.cs" />
127+
<Compile Include="ViewModels\IGitHubConnectSection.cs" />
119128
<Compile Include="ViewModels\IGitHubInvitationSection.cs" />
120129
<Compile Include="ViewModels\IGitHubHomeSection.cs" />
121130
<Compile Include="Models\IProgram.cs" />

src/GitHub.VisualStudio/Helpers/INotifyPropertySource.cs renamed to src/GitHub.Exports/Helpers/INotifyPropertySource.cs

File renamed without changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.ComponentModel;
2+
3+
namespace GitHub.Primitives
4+
{
5+
public abstract class NotificationAwareObject : INotifyPropertyChanged
6+
{
7+
public event PropertyChangedEventHandler PropertyChanged;
8+
9+
public void RaisePropertyChanged(string propertyName)
10+
{
11+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
12+
}
13+
}
14+
}

src/GitHub.VisualStudio/Helpers/PropertyNotifierExtensions.cs renamed to src/GitHub.Exports/Helpers/PropertyNotifierExtensions.cs

File renamed without changes.

0 commit comments

Comments
 (0)