@@ -86,18 +86,11 @@ public async Task Clone(
8686 Assumes . Present ( teamExplorer ) ;
8787
8888#if TEAMEXPLORER14
89- var gitExt = await GetGitRepositoriesExtAsync ( teamExplorer ) ;
90- gitExt . Clone ( cloneUrl , clonePath , recurseSubmodules ? CloneOptions . RecurseSubmodule : CloneOptions . None ) ;
89+ await StartClonenOnConnectPageAsync ( teamExplorer , cloneUrl , clonePath , recurseSubmodules ) ;
90+ await WaitForCloneOnHomePageAsync ( teamExplorer ) ;
9191
92- // First open the target folder in case the user navigates away from the Connect page.
92+ // Show the repository on Team Explorer - Home
9393 vsServices . Value . TryOpenRepository ( clonePath ) ;
94-
95- // The operation will have completed when CanClone goes false and then true again.
96- await gitExt . WhenAnyValue ( x => x . CanClone ) . Where ( x => ! x ) . Take ( 1 ) ; // Wait until started
97- await gitExt . WhenAnyValue ( x => x . CanClone ) . Where ( x => x ) . Take ( 1 ) ; // Wait until completed
98-
99- // Navigate when clone completes, otherwise we'll stop receiving updates to CanClone property.
100- NavigateToHomePage ( teamExplorer ) ;
10194#else
10295 var gitExt = serviceProvider . GetService < IGitActionsExt > ( ) ;
10396 var typedProgress = ( ( Progress < ServiceProgressData > ) progress ) ?? new Progress < ServiceProgressData > ( ) ;
@@ -113,18 +106,34 @@ await Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory.RunAsync(asy
113106#endif
114107 }
115108
116- static void NavigateToHomePage ( ITeamExplorer teamExplorer )
117- {
118- teamExplorer . NavigateToPage ( new Guid ( TeamExplorerPageIds . Home ) , null ) ;
119- }
120-
121- static async Task < IGitRepositoriesExt > GetGitRepositoriesExtAsync ( ITeamExplorer teamExplorer )
109+ static async Task StartClonenOnConnectPageAsync (
110+ ITeamExplorer teamExplorer , string cloneUrl , string clonePath , bool recurseSubmodules )
122111 {
123112 var connectPage = await NavigateToPageAsync ( teamExplorer , new Guid ( TeamExplorerPageIds . Connect ) ) ;
124113 Assumes . Present ( connectPage ) ;
125114 var gitExt = connectPage . GetService < IGitRepositoriesExt > ( ) ;
126115 Assumes . Present ( gitExt ) ;
127- return gitExt ;
116+
117+ gitExt . Clone ( cloneUrl , clonePath , recurseSubmodules ? CloneOptions . RecurseSubmodule : CloneOptions . None ) ;
118+ }
119+
120+ static async Task WaitForCloneOnHomePageAsync ( ITeamExplorer teamExplorer )
121+ {
122+ var homePage = await NavigateToPageAsync ( teamExplorer , new Guid ( TeamExplorerPageIds . Home ) ) ;
123+ Assumes . Present ( homePage ) ;
124+ var gettingStartedSection = homePage . GetSection ( new Guid ( "d0200918-c025-4cc3-9dee-4f5e89d0c918" ) ) ;
125+ Assumes . Present ( gettingStartedSection ) ;
126+
127+ // The clone progress bar appears on the GettingStarted section, so we wait for
128+ // this to be hidden before continuing.
129+ await gettingStartedSection
130+ . WhenAnyValue ( x => x . IsVisible )
131+ . Any ( x => x == false ) ;
132+ }
133+
134+ static void NavigateToHomePage ( ITeamExplorer teamExplorer )
135+ {
136+ teamExplorer . NavigateToPage ( new Guid ( TeamExplorerPageIds . Home ) , null ) ;
128137 }
129138
130139 static async Task < ITeamExplorerPage > NavigateToPageAsync ( ITeamExplorer teamExplorer , Guid pageId )
0 commit comments