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

Commit 27e599f

Browse files
authored
Merge pull request #2219 from github/fixes/2218-clone-on-first-launch
Ensure that clone works when Visual Studio is first launched
2 parents be614d6 + 9def2f9 commit 27e599f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,22 @@ public async Task Clone(
8686
NavigateToHomePage(teamExplorer); // Show progress on Team Explorer - Home
8787
await WaitForCloneOnHomePageAsync(teamExplorer);
8888
#elif TEAMEXPLORER15 || TEAMEXPLORER16
89+
// IGitActionsExt is proffered by SccProviderPackage, but isn't advertised.
90+
// To ensure that getting IGitActionsExt doesn't return null, we first request the
91+
// IGitExt service which is advertised. This forces SccProviderPackage to load
92+
// and proffer IGitActionsExt.
93+
var gitExt = serviceProvider.GetService(typeof(IGitExt));
94+
Assumes.NotNull(gitExt);
95+
var gitActionsExt = serviceProvider.GetService<IGitActionsExt>();
96+
Assumes.NotNull(gitActionsExt);
97+
8998
// The progress parameter uses the ServiceProgressData type which is defined in
9099
// Microsoft.VisualStudio.Shell.Framework. Referencing this assembly directly
91100
// would cause type conflicts, so we're using reflection to call CloneAsync.
92-
var gitExt = serviceProvider.GetService<IGitActionsExt>();
93101
var cloneAsyncMethod = typeof(IGitActionsExt).GetMethod(nameof(IGitActionsExt.CloneAsync));
94102
Assumes.NotNull(cloneAsyncMethod);
95103
var cloneParameters = new object[] { cloneUrl, clonePath, recurseSubmodules, cancellationToken, progress };
96-
var cloneTask = (Task)cloneAsyncMethod.Invoke(gitExt, cloneParameters);
104+
var cloneTask = (Task)cloneAsyncMethod.Invoke(gitActionsExt, cloneParameters);
97105

98106
NavigateToHomePage(teamExplorer); // Show progress on Team Explorer - Home
99107
await cloneTask;

0 commit comments

Comments
 (0)