@@ -12,7 +12,8 @@ abstract class ApplicationManagerBase : IApplicationManager
1212 protected static ILogging Logger { get ; } = LogHelper . GetLogger < IApplicationManager > ( ) ;
1313
1414 private RepositoryManager repositoryManager ;
15- private Progress progressReporter ;
15+ private ProgressReporter progressReporter = new ProgressReporter ( ) ;
16+ private Progress progress = new Progress ( TaskBase . Default ) ;
1617 protected bool isBusy ;
1718 private bool firstRun ;
1819 protected bool FirstRun { get { return firstRun ; } set { firstRun = value ; } }
@@ -27,13 +28,13 @@ public event Action<IProgress> OnProgress
2728
2829 public ApplicationManagerBase ( SynchronizationContext synchronizationContext )
2930 {
30- progressReporter = new Progress ( ) ;
3131 SynchronizationContext = synchronizationContext ;
3232 SynchronizationContext . SetSynchronizationContext ( SynchronizationContext ) ;
3333 ThreadingHelper . SetUIThread ( ) ;
3434 UIScheduler = TaskScheduler . FromCurrentSynchronizationContext ( ) ;
3535 ThreadingHelper . MainThreadScheduler = UIScheduler ;
3636 TaskManager = new TaskManager ( UIScheduler ) ;
37+ progress . OnProgress += progressReporter . UpdateProgress ;
3738 }
3839
3940 protected void Initialize ( )
@@ -51,6 +52,7 @@ protected void Initialize()
5152 public void Run ( )
5253 {
5354 isBusy = true ;
55+ progress . UpdateProgress ( 0 , 100 , "Initializing..." ) ;
5456
5557 var thread = new Thread ( ( ) =>
5658 {
@@ -72,8 +74,13 @@ public void Run()
7274 }
7375 }
7476
75- var installer = new GitInstaller ( Environment , ProcessManager , CancellationToken )
76- { Progress = progressReporter } ;
77+ progress . UpdateProgress ( 20 , 100 , "Setting up octorun..." ) ;
78+
79+ Environment . OctorunScriptPath = new OctorunInstaller ( Environment , TaskManager )
80+ . SetupOctorunIfNeeded ( ) ;
81+
82+ progress . UpdateProgress ( 50 , 100 , "Setting up git..." ) ;
83+
7784 state = Environment . GitInstallationState ;
7885 if ( ! state . GitIsValid && ! state . GitLfsIsValid && FirstRun )
7986 {
@@ -88,6 +95,9 @@ public void Run()
8895 }
8996 }
9097
98+
99+ var installer = new GitInstaller ( Environment , ProcessManager , CancellationToken ) ;
100+ installer . Progress . OnProgress += progressReporter . UpdateProgress ;
91101 if ( state . GitIsValid && state . GitLfsIsValid )
92102 {
93103 if ( firstRun )
@@ -100,25 +110,26 @@ public void Run()
100110 }
101111 }
102112
103- Environment . OctorunScriptPath = new OctorunInstaller ( Environment , TaskManager )
104- . SetupOctorunIfNeeded ( ) ;
105-
106113 if ( ! state . GitIsValid || ! state . GitLfsIsValid )
107114 {
108115 state = installer . SetupGitIfNeeded ( ) ;
109116 }
110117
111118 SetupGit ( state ) ;
112119
120+ progress . UpdateProgress ( 80 , 100 , "Initializing repository..." ) ;
121+
113122 if ( state . GitIsValid && state . GitLfsIsValid )
114123 {
115124 RestartRepository ( ) ;
116125 }
117126
127+ progress . UpdateProgress ( 100 , 100 , "Initialization failed" ) ;
118128 }
119129 catch ( Exception ex )
120130 {
121131 Logger . Error ( ex , "A problem ocurred setting up Git" ) ;
132+ progress . UpdateProgress ( 90 , 100 , "Initialization failed" ) ;
122133 }
123134
124135 new ActionTask < bool > ( CancellationToken , ( s , gitIsValid ) =>
@@ -204,6 +215,7 @@ public void SetupGit(GitInstaller.GitInstallationState state)
204215 public void InitializeRepository ( )
205216 {
206217 isBusy = true ;
218+ progress . UpdateProgress ( 0 , 100 , "Initializing..." ) ;
207219 var thread = new Thread ( ( ) =>
208220 {
209221 var success = true ;
@@ -218,27 +230,37 @@ public void InitializeRepository()
218230 var filesForInitialCommit = new List < string > { gitignore , gitAttrs , assetsGitignore } ;
219231
220232 GitClient . Init ( ) . RunWithReturn ( true ) ;
233+ progress . UpdateProgress ( 10 , 100 , "Initializing..." ) ;
221234
222235 ConfigureMergeSettings ( ) ;
236+ progress . UpdateProgress ( 20 , 100 , "Initializing..." ) ;
237+
223238 GitClient . LfsInstall ( ) . RunWithReturn ( true ) ;
239+ progress . UpdateProgress ( 30 , 100 , "Initializing..." ) ;
240+
224241 AssemblyResources . ToFile ( ResourceType . Generic , ".gitignore" , targetPath , Environment ) ;
225242 AssemblyResources . ToFile ( ResourceType . Generic , ".gitattributes" , targetPath , Environment ) ;
226243 assetsGitignore . CreateFile ( ) ;
227244 GitClient . Add ( filesForInitialCommit ) . RunWithReturn ( true ) ;
245+ progress . UpdateProgress ( 60 , 100 , "Initializing..." ) ;
228246 GitClient . Commit ( "Initial commit" , null ) . RunWithReturn ( true ) ;
247+ progress . UpdateProgress ( 70 , 100 , "Initializing..." ) ;
229248 Environment . InitializeRepository ( ) ;
230249 UsageTracker . IncrementProjectsInitialized ( ) ;
231250 }
232251 catch ( Exception ex )
233252 {
234253 Logger . Error ( ex , "A problem ocurred initializing the repository" ) ;
254+ progress . UpdateProgress ( 90 , 100 , "Failed to initialize repository" ) ;
235255 success = false ;
236256 }
237257
238258 if ( success )
239259 {
260+ progress . UpdateProgress ( 90 , 100 , "Initializing..." ) ;
240261 RestartRepository ( ) ;
241262 TaskManager . RunInUI ( InitializeUI ) ;
263+ progress . UpdateProgress ( 100 , 100 , "Initialized" ) ;
242264 }
243265 isBusy = false ;
244266 } ) ;
0 commit comments