-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix cloning using Open From GitHub on Visual Studio 2015 #1982
Fix cloning using Open From GitHub on Visual Studio 2015 #1982
Conversation
Codecov Report
@@ Coverage Diff @@
## release/2.5.8 #1982 +/- ##
================================================
Coverage ? 41.04%
================================================
Files ? 403
Lines ? 17167
Branches ? 2381
================================================
Hits ? 7047
Misses ? 9568
Partials ? 552
|
f4f3ddd
to
d877773
Compare
Stop relying on the state of IGitHubServiceProvider to locate IGitRepositoriesExt.
There's no more need to explicitly show the Team Explorer - Connect page when the Start Page GitHub button is clicked. This will happen automatically before cloning.
A clone progress bar and option to cancel appears on Team Explorer - Home while cloning. Navigate to Team Explorer - Home, when clone operation is about to start.
We want the Clone behavior to be as similar as possible on Visual Studio 2015 and 2017.
This gives user an opportunity to choose a solution.
If the user navigates away from the Connect page, the CanClone property will stop updating and the Clone method won't return. Point Team Explorer at the target folder when clone starts incase this happens.
Detect when a clone completes by waiting for the clone progress bar on the Team Explorer Home page to be hidden.
Look for clone progress bar on any Team Explorer Home page that the user navigates to. The Home page will need to be the topmost page on Team Explorer for the clone to complete.
- Be consistent between 2015 and 2017 by navigating to Home page after clone starts. - There's no need to use JoinableTaskFactory.RunAsync when a task is being awaited.
Move NavigateToHomePage out of WaitForCloneOnHomePageAsync to show the stages more clearly.
10c038a
to
567d490
Compare
I just confirmed that this worked on VS2015 Community 👍 Looks like there is still a build failing though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM other than the build that's failing ✨
@@ -59,7 +57,6 @@ async Task<CodeContainer> RunAcquisition(IProgress<ServiceProgressData> download | |||
try | |||
{ | |||
var uiProvider = await Task.Run(() => Package.GetGlobalService(typeof(IGitHubServiceProvider)) as IGitHubServiceProvider); | |||
await ShowTeamExplorerPage(uiProvider); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this was the piece that was waiting for the Team Explorer to let us know that the clone had completed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a hack to make the IGitRepositoriesExt
service available later on when the Clone
method attempts to retrieve it from IGitHubServiceProvider
.
The problem was that it required two pieces to be in place before it wold work.
- The
Team Explorer - Connext
page must be visible - Something must have set the
GitServiceProvider
onIGitHubServiceProvider
This was way too fragile and the reason the bug crept in.
@@ -39,6 +36,8 @@ public class VSGitServices : IVSGitServices | |||
|
|||
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Used in VS2017")] | |||
readonly Lazy<IStatusBarNotificationService> statusBar; | |||
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Used in VS2015")] | |||
readonly Lazy<IVSServices> vsServices; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you quickly explain this bit for my edification?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a TryOpenRepository
method on IVSServices
that we only need to call when running on Visual Studio 2015. On Visual Studio 2017, the cloned repository automatically opens in folder view (which is new in Visual Studio 2017).
If we didn't call TryOpenRepository
, you wouldn't see the URL change on Team Explorer - Home
and there'd be no option to open a solution. You'd need to manually find and open a solution in the cloned folder.
// The operation will have completed when CanClone goes false and then true again. | ||
await gitExt.WhenAnyValue(x => x.CanClone).Where(x => !x).Take(1); | ||
await gitExt.WhenAnyValue(x => x.CanClone).Where(x => x).Take(1); | ||
#if TEAMEXPLORER14 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is the new bit right? So instead of waiting for the response from TE, we're starting the clone and immediately navigating to the TE Home page and then the user will see the TE change as a result of the clone completing but TE is handling that. And we can identify that change (instead of actually waiting for an update from TE)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can infer that the clone operation has completed when the progress bar is hidden and automatically change context to the newly cloned repository. If we didn't change repository context at this point, the user would know the clone had completed, but they'd be left to find and open a solution from the newly cloned folder (not a nice experience).
static async Task WaitForCloneOnHomePageAsync(ITeamExplorer teamExplorer) | ||
{ | ||
// The clone progress bar appears on the GettingStartedSection of the Home page, | ||
// so we wait for this to be hidden before continuing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨
If no events arrive default to invisible. Watch the topmost section.
We don't want to change context when a clone operation has failed.
This PR targets release/2.5.8
The aim of this PR is to make
VSGitServices.Clone
work as consistently as possible on Visual Studio 2015 and 2017. The clone operation should do the following on both versions:Team Explorer - Home
On Visual Studio 2017 the cloned repository will be opened as a Folder in
Solution Explorer
. This happens automatically when a repository is cloned and is equivalent to using the newFile > Open > Folder...
) command.On Visual Studio 2015 the
Team Explorer
context is changed (usingVSService.TryOpenRepository
), but the Folder view doesn't exist on Visual Studio 2015.What this PR does
IGitRepositoriesExt
service can always be foundTeam Explorer - Home
while cloning.git
folder)Throttle
to avoid false positives if progress bar glitches hiddenStartWith(false)
so clone doesn't wait forever if progress section never appearsHow to test
The following should work on Visual Studio 2015 and 2017
File > Open > Open from GitHub...
dotnet/BenchmarkDotNet
on URL tab)Clone
buttonTeam Explorer - Home
When a clone operation fails
File > Open > Open from GitHub...
foo/bar
on URL tab)Clone
buttonFailed to clone...
notification to appearCancel
buttonOn Visual Studio 2015, clone completion will only be detected when
Team Explorer - Home
is the topmost page inTeam Explorer
. You can confirm this by doing the following:File > Open > Open from GitHub...
dotnet/BenchmarkDotNet
on URL tab)Clone
buttonManage Connections
, which will navigate toTeam Explorer - Connect
.Home
, which will navigate toTeam Explorer - Home
Team Explorer - Home
is visibleI tested some of the Rx logic using the following test:
Fixes #1981, Fixes #1982