@@ -51,62 +51,70 @@ public void Run()
51
51
52
52
var thread = new Thread ( obj =>
53
53
{
54
+ GitInstallationState state = new GitInstallationState ( ) ;
54
55
CancellationToken token = ( CancellationToken ) obj ;
55
- SetupMetrics ( Environment . UnityVersion , firstRun , instanceId ) ;
56
-
57
- if ( Environment . IsMac )
56
+ try
58
57
{
59
- var getEnvPath = new SimpleProcessTask ( token , "bash" . ToNPath ( ) , "-c \" /usr/libexec/path_helper\" " )
60
- . Configure ( ProcessManager , dontSetupGit : true )
61
- . Catch ( e => true ) ; // make sure this doesn't throw if the task fails
62
- var path = getEnvPath . RunWithReturn ( true ) ;
63
- if ( getEnvPath . Successful )
58
+ SetupMetrics ( Environment . UnityVersion , firstRun , instanceId ) ;
59
+
60
+ if ( Environment . IsMac )
64
61
{
65
- Logger . Trace ( "Existing Environment Path Original:{0} Updated:{1}" , Environment . Path , path ) ;
66
- Environment . Path = path ? . Split ( new [ ] { "\" " } , StringSplitOptions . None ) [ 1 ] ;
62
+ var getEnvPath = new SimpleProcessTask ( token , "bash" . ToNPath ( ) , "-c \" /usr/libexec/path_helper\" " )
63
+ . Configure ( ProcessManager , dontSetupGit : true )
64
+ . Catch ( e => true ) ; // make sure this doesn't throw if the task fails
65
+ var path = getEnvPath . RunWithReturn ( true ) ;
66
+ if ( getEnvPath . Successful )
67
+ {
68
+ Logger . Trace ( "Existing Environment Path Original:{0} Updated:{1}" , Environment . Path , path ) ;
69
+ Environment . Path = path ? . Split ( new [ ] { "\" " } , StringSplitOptions . None ) [ 1 ] ;
70
+ }
67
71
}
68
- }
69
72
70
- GitInstallationState state = new GitInstallationState ( ) ;
71
- bool skipInstallers = false ;
72
- state = SystemSettings . Get < GitInstallationState > ( Constants . GitInstallationState ) ?? state ;
73
- var now = DateTimeOffset . Now ;
74
- if ( now . Date == state . GitLastCheckTime . Date && state . GitIsValid && state . GitLfsIsValid )
75
- {
76
- // just check if the git/git lfs version is what we need
77
- if ( firstRun )
73
+ bool skipInstallers = false ;
74
+ state = SystemSettings . Get < GitInstallationState > ( Constants . GitInstallationState ) ?? state ;
75
+ var now = DateTimeOffset . Now ;
76
+ if ( now . Date == state . GitLastCheckTime . Date && state . GitIsValid && state . GitLfsIsValid )
78
77
{
79
- var version = new GitVersionTask ( token )
80
- . Configure ( ProcessManager , state . GitExecutablePath , dontSetupGit : true )
81
- . Catch ( e => true )
82
- . RunWithReturn ( true ) ;
83
- state . GitIsValid = version >= Constants . MinimumGitVersion ;
84
- if ( state . GitIsValid )
78
+ // just check if the git/git lfs version is what we need
79
+ if ( firstRun )
85
80
{
86
- version = new GitLfsVersionTask ( token )
87
- . Configure ( ProcessManager , state . GitLfsExecutablePath , dontSetupGit : true )
88
- . Catch ( e => true )
89
- . RunWithReturn ( true ) ;
90
- state . GitLfsIsValid = version >= Constants . MinimumGitLfsVersion ;
81
+ var version = new GitVersionTask ( token )
82
+ . Configure ( ProcessManager , state . GitExecutablePath , dontSetupGit : true )
83
+ . Catch ( e => true )
84
+ . RunWithReturn ( true ) ;
85
+ state . GitIsValid = version >= Constants . MinimumGitVersion ;
86
+ if ( state . GitIsValid )
87
+ {
88
+ version = new GitLfsVersionTask ( token )
89
+ . Configure ( ProcessManager , state . GitLfsExecutablePath , dontSetupGit : true )
90
+ . Catch ( e => true )
91
+ . RunWithReturn ( true ) ;
92
+ state . GitLfsIsValid = version >= Constants . MinimumGitLfsVersion ;
93
+ }
91
94
}
92
95
}
93
- }
94
96
95
- if ( ! skipInstallers )
96
- {
97
- Environment . OctorunScriptPath = new OctorunInstaller ( Environment , TaskManager )
98
- . SetupOctorunIfNeeded ( ) ;
97
+ if ( ! skipInstallers )
98
+ {
99
+ Environment . OctorunScriptPath = new OctorunInstaller ( Environment , TaskManager )
100
+ . SetupOctorunIfNeeded ( ) ;
99
101
100
- state = new GitInstaller ( Environment , ProcessManager , CancellationToken , SystemSettings )
101
- { Progress = progressReporter }
102
- . SetupGitIfNeeded ( ) ;
103
- }
102
+ state = new GitInstaller ( Environment , ProcessManager , CancellationToken , SystemSettings )
103
+ { Progress = progressReporter }
104
+ . SetupGitIfNeeded ( ) ;
105
+ }
104
106
105
- SetupGit ( state ) ;
107
+ SetupGit ( state ) ;
106
108
107
- if ( state . GitIsValid && state . GitLfsIsValid )
109
+ if ( state . GitIsValid && state . GitLfsIsValid )
110
+ {
111
+ RestartRepository ( ) ;
112
+ }
113
+
114
+ }
115
+ catch ( Exception ex )
108
116
{
109
- RestartRepository ( ) ;
117
+ Logger . Error ( ex , "A problem ocurred setting up Git" ) ;
110
118
}
111
119
112
120
new ActionTask < bool > ( token , ( s , gitIsValid ) =>
@@ -185,28 +193,43 @@ public void SetupGit(GitInstaller.GitInstallationState state)
185
193
186
194
public void InitializeRepository ( )
187
195
{
196
+ isBusy = true ;
188
197
var thread = new Thread ( obj =>
189
198
{
199
+ var success = true ;
190
200
CancellationToken token = ( CancellationToken ) obj ;
191
- var targetPath = NPath . CurrentDirectory ;
192
-
193
- var gitignore = targetPath . Combine ( ".gitignore" ) ;
194
- var gitAttrs = targetPath . Combine ( ".gitattributes" ) ;
195
- var assetsGitignore = targetPath . Combine ( "Assets" , ".gitignore" ) ;
196
-
197
- var filesForInitialCommit = new List < string > { gitignore , gitAttrs , assetsGitignore } ;
201
+ try
202
+ {
203
+ var targetPath = NPath . CurrentDirectory ;
204
+
205
+ var gitignore = targetPath . Combine ( ".gitignore" ) ;
206
+ var gitAttrs = targetPath . Combine ( ".gitattributes" ) ;
207
+ var assetsGitignore = targetPath . Combine ( "Assets" , ".gitignore" ) ;
208
+
209
+ var filesForInitialCommit = new List < string > { gitignore , gitAttrs , assetsGitignore } ;
210
+
211
+ GitClient . Init ( ) . RunWithReturn ( true ) ;
212
+ GitClient . LfsInstall ( ) . RunWithReturn ( true ) ;
213
+ AssemblyResources . ToFile ( ResourceType . Generic , ".gitignore" , targetPath , Environment ) ;
214
+ AssemblyResources . ToFile ( ResourceType . Generic , ".gitattributes" , targetPath , Environment ) ;
215
+ assetsGitignore . CreateFile ( ) ;
216
+ GitClient . Add ( filesForInitialCommit ) . RunWithReturn ( true ) ;
217
+ GitClient . Commit ( "Initial commit" , null ) . RunWithReturn ( true ) ;
218
+ Environment . InitializeRepository ( ) ;
219
+ UsageTracker . IncrementProjectsInitialized ( ) ;
220
+ }
221
+ catch ( Exception ex )
222
+ {
223
+ Logger . Error ( ex , "A problem ocurred initializing the repository" ) ;
224
+ success = false ;
225
+ }
198
226
199
- GitClient . Init ( ) . RunWithReturn ( true ) ;
200
- GitClient . LfsInstall ( ) . RunWithReturn ( true ) ;
201
- AssemblyResources . ToFile ( ResourceType . Generic , ".gitignore" , targetPath , Environment ) ;
202
- AssemblyResources . ToFile ( ResourceType . Generic , ".gitattributes" , targetPath , Environment ) ;
203
- assetsGitignore . CreateFile ( ) ;
204
- GitClient . Add ( filesForInitialCommit ) . RunWithReturn ( true ) ;
205
- GitClient . Commit ( "Initial commit" , null ) . RunWithReturn ( true ) ;
206
- Environment . InitializeRepository ( ) ;
207
- RestartRepository ( ) ;
208
- UsageTracker . IncrementProjectsInitialized ( ) ;
209
- TaskManager . RunInUI ( InitializeUI ) ;
227
+ if ( success )
228
+ {
229
+ RestartRepository ( ) ;
230
+ TaskManager . RunInUI ( InitializeUI ) ;
231
+ }
232
+ isBusy = false ;
210
233
} ) ;
211
234
thread . Start ( CancellationToken ) ;
212
235
}
0 commit comments