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

Commit f93fdf4

Browse files
authored
Merge branch 'master' into feature/save-drafts
2 parents 857f094 + adb4119 commit f93fdf4

19 files changed

+448
-41
lines changed

GitHubVS.sln

+12
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactiveUI.Wpf", "submodule
133133
EndProject
134134
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InstallAndStart", "test\Launcher\InstallAndStart.csproj", "{79F32BE1-2764-4DBA-97F6-21053DE44270}"
135135
EndProject
136+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.TeamFoundation.16", "src\GitHub.TeamFoundation.16\GitHub.TeamFoundation.16.csproj", "{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}"
137+
EndProject
136138
Global
137139
GlobalSection(SolutionConfigurationPlatforms) = preSolution
138140
Debug|Any CPU = Debug|Any CPU
@@ -542,6 +544,16 @@ Global
542544
{79F32BE1-2764-4DBA-97F6-21053DE44270}.Release|Any CPU.Build.0 = Release|Any CPU
543545
{79F32BE1-2764-4DBA-97F6-21053DE44270}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
544546
{79F32BE1-2764-4DBA-97F6-21053DE44270}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
547+
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
548+
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
549+
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.DebugCodeAnalysis|Any CPU.ActiveCfg = DebugCodeAnalysis|Any CPU
550+
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.DebugCodeAnalysis|Any CPU.Build.0 = DebugCodeAnalysis|Any CPU
551+
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.DebugWithoutVsix|Any CPU.ActiveCfg = DebugCodeAnalysis|Any CPU
552+
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.DebugWithoutVsix|Any CPU.Build.0 = DebugCodeAnalysis|Any CPU
553+
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
554+
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.Release|Any CPU.Build.0 = Release|Any CPU
555+
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
556+
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
545557
EndGlobalSection
546558
GlobalSection(SolutionProperties) = preSolution
547559
HideSolutionNode = FALSE
1.39 MB
Binary file not shown.
698 KB
Binary file not shown.
1.09 MB
Binary file not shown.
36.8 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.

src/GitHub.TeamFoundation.14/Connect/GitHubConnectSection.cs

+23-13
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
using System.Collections.Specialized;
33
using System.ComponentModel;
44
using System.Globalization;
5+
using System.IO;
56
using System.Linq;
6-
using System.Reactive;
77
using System.Reactive.Linq;
8-
using System.Reactive.Subjects;
98
using System.Threading.Tasks;
109
using System.Windows.Input;
1110
using GitHub.Api;
@@ -15,7 +14,6 @@
1514
using GitHub.Primitives;
1615
using GitHub.Services;
1716
using GitHub.Settings;
18-
using GitHub.UI;
1917
using GitHub.VisualStudio.Base;
2018
using GitHub.VisualStudio.Helpers;
2119
using GitHub.VisualStudio.UI;
@@ -31,7 +29,7 @@ public class GitHubConnectSection : TeamExplorerSectionBase, IGitHubConnectSecti
3129
{
3230
static readonly ILogger log = LogManager.ForContext<GitHubConnectSection>();
3331
readonly IPackageSettings packageSettings;
34-
readonly IVSServices vsServices;
32+
readonly ITeamExplorerServices teamExplorerServices;
3533
readonly int sectionIndex;
3634
readonly ILocalRepositories localRepositories;
3735
readonly IUsageTracker usageTracker;
@@ -110,7 +108,7 @@ public GitHubConnectSection(IGitHubServiceProvider serviceProvider,
110108
ITeamExplorerServiceHolder holder,
111109
IConnectionManager manager,
112110
IPackageSettings packageSettings,
113-
IVSServices vsServices,
111+
ITeamExplorerServices teamExplorerServices,
114112
ILocalRepositories localRepositories,
115113
IUsageTracker usageTracker,
116114
int index)
@@ -120,7 +118,7 @@ public GitHubConnectSection(IGitHubServiceProvider serviceProvider,
120118
Guard.ArgumentNotNull(holder, nameof(holder));
121119
Guard.ArgumentNotNull(manager, nameof(manager));
122120
Guard.ArgumentNotNull(packageSettings, nameof(packageSettings));
123-
Guard.ArgumentNotNull(vsServices, nameof(vsServices));
121+
Guard.ArgumentNotNull(teamExplorerServices, nameof(teamExplorerServices));
124122
Guard.ArgumentNotNull(localRepositories, nameof(localRepositories));
125123
Guard.ArgumentNotNull(usageTracker, nameof(usageTracker));
126124

@@ -130,7 +128,7 @@ public GitHubConnectSection(IGitHubServiceProvider serviceProvider,
130128
sectionIndex = index;
131129

132130
this.packageSettings = packageSettings;
133-
this.vsServices = vsServices;
131+
this.teamExplorerServices = teamExplorerServices;
134132
this.localRepositories = localRepositories;
135133
this.usageTracker = usageTracker;
136134

@@ -462,15 +460,27 @@ public bool OpenRepository()
462460
var old = Repositories.FirstOrDefault(x => x.Equals(Holder.ActiveRepo));
463461
if (!Equals(SelectedRepository, old))
464462
{
465-
var opened = vsServices.TryOpenRepository(SelectedRepository.LocalPath);
466-
if (!opened)
463+
try
467464
{
468-
// TryOpenRepository might fail because dir no longer exists. Let user find solution themselves.
469-
opened = ErrorHandler.Succeeded(ServiceProvider.GetSolution().OpenSolutionViaDlg(SelectedRepository.LocalPath, 1));
470-
if (!opened)
465+
var repositoryPath = SelectedRepository.LocalPath;
466+
if (Directory.Exists(repositoryPath))
471467
{
472-
return false;
468+
teamExplorerServices.OpenRepository(SelectedRepository.LocalPath);
473469
}
470+
else
471+
{
472+
// If directory no longer exists, let user find solution themselves
473+
var opened = ErrorHandler.Succeeded(ServiceProvider.GetSolution().OpenSolutionViaDlg(SelectedRepository.LocalPath, 1));
474+
if (!opened)
475+
{
476+
return false;
477+
}
478+
}
479+
}
480+
catch (Exception e)
481+
{
482+
log.Error(e, nameof(OpenRepository));
483+
return false;
474484
}
475485
}
476486

src/GitHub.TeamFoundation.14/Connect/GitHubConnectSection0.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ public GitHubConnectSection0(IGitHubServiceProvider serviceProvider,
1818
ITeamExplorerServiceHolder holder,
1919
IConnectionManager manager,
2020
IPackageSettings settings,
21-
IVSServices vsServices,
21+
ITeamExplorerServices teamExplorerServices,
2222
ILocalRepositories localRepositories,
2323
IUsageTracker usageTracker)
24-
: base(serviceProvider, apiFactory, holder, manager, settings, vsServices, localRepositories, usageTracker, 0)
24+
: base(serviceProvider, apiFactory, holder, manager, settings, teamExplorerServices, localRepositories, usageTracker, 0)
2525
{
2626
}
2727
}

src/GitHub.TeamFoundation.14/Connect/GitHubConnectSection1.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ public GitHubConnectSection1(IGitHubServiceProvider serviceProvider,
1818
ITeamExplorerServiceHolder holder,
1919
IConnectionManager manager,
2020
IPackageSettings settings,
21-
IVSServices vsServices,
21+
ITeamExplorerServices teamExplorerServices,
2222
ILocalRepositories localRepositories,
2323
IUsageTracker usageTracker)
24-
: base(serviceProvider, apiFactory, holder, manager, settings, vsServices, localRepositories, usageTracker, 1)
24+
: base(serviceProvider, apiFactory, holder, manager, settings, teamExplorerServices, localRepositories, usageTracker, 1)
2525
{
2626
}
2727
}

src/GitHub.TeamFoundation.14/Services/VSGitExt.cs

+6-7
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,26 @@ public class VSGitExt : IVSGitExt
2626
{
2727
static readonly ILogger log = LogManager.ForContext<VSGitExt>();
2828

29-
readonly IAsyncServiceProvider asyncServiceProvider;
29+
readonly IServiceProvider serviceProvider;
3030
readonly ILocalRepositoryModelFactory repositoryFactory;
3131
readonly object refreshLock = new object();
3232

3333
IGitExt gitService;
3434
IReadOnlyList<ILocalRepositoryModel> activeRepositories;
3535

36-
public VSGitExt(IAsyncServiceProvider asyncServiceProvider)
37-
: this(asyncServiceProvider, new VSUIContextFactory(), new LocalRepositoryModelFactory(), ThreadHelper.JoinableTaskContext)
36+
public VSGitExt(IServiceProvider serviceProvider)
37+
: this(serviceProvider, new VSUIContextFactory(), new LocalRepositoryModelFactory(), ThreadHelper.JoinableTaskContext)
3838
{
3939
}
4040

41-
public VSGitExt(IAsyncServiceProvider asyncServiceProvider, IVSUIContextFactory factory, ILocalRepositoryModelFactory repositoryFactory,
41+
public VSGitExt(IServiceProvider serviceProvider, IVSUIContextFactory factory, ILocalRepositoryModelFactory repositoryFactory,
4242
JoinableTaskContext joinableTaskContext)
4343
{
4444
JoinableTaskCollection = joinableTaskContext.CreateCollection();
4545
JoinableTaskCollection.DisplayName = nameof(VSGitExt);
4646
JoinableTaskFactory = joinableTaskContext.CreateFactory(JoinableTaskCollection);
4747

48-
this.asyncServiceProvider = asyncServiceProvider;
48+
this.serviceProvider = serviceProvider;
4949
this.repositoryFactory = repositoryFactory;
5050

5151
// Start with empty array until we have a chance to initialize.
@@ -133,10 +133,9 @@ public void JoinTillEmpty()
133133
async Task<T> GetServiceAsync<T>()
134134
{
135135
await JoinableTaskFactory.SwitchToMainThreadAsync();
136-
return (T)await asyncServiceProvider.GetServiceAsync(typeof(T));
136+
return (T)serviceProvider.GetService(typeof(T));
137137
}
138138

139-
140139
public event Action ActiveRepositoriesChanged;
141140

142141
JoinableTaskCollection JoinableTaskCollection { get; }

src/GitHub.TeamFoundation.14/Services/VSGitServices.cs

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !TEAMEXPLORER14
1+
#if TEAMEXPLORER15
22
// Microsoft.VisualStudio.Shell.Framework has an alias to avoid conflict with IAsyncServiceProvider
33
extern alias SF15;
44
using ServiceProgressData = SF15::Microsoft.VisualStudio.Shell.ServiceProgressData;
@@ -90,12 +90,24 @@ public async Task Clone(
9090
await StartClonenOnConnectPageAsync(teamExplorer, cloneUrl, clonePath, recurseSubmodules);
9191
NavigateToHomePage(teamExplorer); // Show progress on Team Explorer - Home
9292
await WaitForCloneOnHomePageAsync(teamExplorer);
93-
#else
93+
#elif TEAMEXPLORER15
9494
var gitExt = serviceProvider.GetService<IGitActionsExt>();
9595
var typedProgress = ((Progress<ServiceProgressData>)progress) ?? new Progress<ServiceProgressData>();
9696
typedProgress.ProgressChanged += (s, e) => statusBar.Value.ShowMessage(e.ProgressText);
9797
var cloneTask = gitExt.CloneAsync(cloneUrl, clonePath, recurseSubmodules, default(CancellationToken), typedProgress);
9898

99+
NavigateToHomePage(teamExplorer); // Show progress on Team Explorer - Home
100+
await cloneTask;
101+
#elif TEAMEXPLORER16
102+
// The ServiceProgressData type is in a Visual Studio 2019 assembly that we don't currently have access to.
103+
// Using reflection to call the CloneAsync in order to avoid conflicts with the Visual Studio 2017 version.
104+
// Progress won't be displayed on the status bar, but it appears prominently on the Team Explorer Home view.
105+
var gitExt = serviceProvider.GetService<IGitActionsExt>();
106+
var cloneAsyncMethod = typeof(IGitActionsExt).GetMethod(nameof(IGitActionsExt.CloneAsync));
107+
Assumes.NotNull(cloneAsyncMethod);
108+
var cloneParameters = new object[] { cloneUrl, clonePath, recurseSubmodules, default(CancellationToken), null };
109+
var cloneTask = (Task)cloneAsyncMethod.Invoke(gitExt, cloneParameters);
110+
99111
NavigateToHomePage(teamExplorer); // Show progress on Team Explorer - Home
100112
await cloneTask;
101113
#endif

0 commit comments

Comments
 (0)