43
43
#define kToolInstallPath @" /usr/local/bin/" kToolName
44
44
45
45
@interface AppDelegate () <NSUserNotificationCenterDelegate , SUUpdaterDelegate>
46
- @property (nonatomic , strong ) AboutWindowController * aboutWindowController;
47
- @property (nonatomic , strong ) CloneWindowController * cloneWindowController;
48
- @property (nonatomic , strong ) PreferencesWindowController * preferencesWindowController;
49
- @property (nonatomic , strong ) WelcomeWindowController * welcomeWindowController;
46
+ @property (nonatomic , strong ) AboutWindowController* aboutWindowController;
47
+ @property (nonatomic , strong ) CloneWindowController* cloneWindowController;
48
+ @property (nonatomic , strong ) PreferencesWindowController* preferencesWindowController;
49
+ @property (nonatomic , strong ) WelcomeWindowController* welcomeWindowController;
50
50
@end
51
51
52
52
@implementation AppDelegate {
@@ -59,14 +59,14 @@ @implementation AppDelegate {
59
59
60
60
#pragma mark - Properties
61
61
62
- - (AboutWindowController *)aboutWindowController {
62
+ - (AboutWindowController*)aboutWindowController {
63
63
if (!_aboutWindowController) {
64
64
_aboutWindowController = [[AboutWindowController alloc ] init ];
65
65
}
66
66
return _aboutWindowController;
67
67
}
68
68
69
- - (CloneWindowController *)cloneWindowController {
69
+ - (CloneWindowController*)cloneWindowController {
70
70
if (!_cloneWindowController) {
71
71
_cloneWindowController = [[CloneWindowController alloc ] init ];
72
72
}
@@ -80,7 +80,7 @@ - (void)didChangeReleaseChannel:(BOOL)didChange {
80
80
}
81
81
}
82
82
83
- - (PreferencesWindowController *)preferencesWindowController {
83
+ - (PreferencesWindowController*)preferencesWindowController {
84
84
if (!_preferencesWindowController) {
85
85
_preferencesWindowController = [[PreferencesWindowController alloc ] init ];
86
86
__weak typeof (self) weakSelf = self;
@@ -91,17 +91,16 @@ - (PreferencesWindowController *)preferencesWindowController {
91
91
return _preferencesWindowController;
92
92
}
93
93
94
- - (WelcomeWindowController *)welcomeWindowController {
94
+ - (WelcomeWindowController*)welcomeWindowController {
95
95
if (!_welcomeWindowController) {
96
96
_welcomeWindowController = [[WelcomeWindowController alloc ] init ];
97
-
97
+
98
98
_welcomeWindowController.keyShouldShowWindow = kUserDefaultsKey_ShowWelcomeWindow ;
99
-
99
+
100
100
__weak typeof (self) weakSelf = self;
101
- _welcomeWindowController.openDocumentAtURL = ^(NSURL * _Nonnull url) {
101
+ _welcomeWindowController.openDocumentAtURL = ^(NSURL * _Nonnull url) {
102
102
[weakSelf _openDocumentAtURL: url];
103
103
};
104
-
105
104
}
106
105
return _welcomeWindowController;
107
106
}
@@ -153,7 +152,7 @@ - (void)_openRepositoryWithURL:(NSURL*)url withCloneMode:(CloneMode)cloneMode wi
153
152
}];
154
153
}
155
154
156
- - (void )_openDocumentAtURL : (NSURL *)url {
155
+ - (void )_openDocumentAtURL : (NSURL *)url {
157
156
[self _openRepositoryWithURL: url withCloneMode: kCloneMode_None windowModeID: NSNotFound ];
158
157
}
159
158
@@ -210,13 +209,13 @@ - (void)applicationDidFinishLaunching:(NSNotification*)notification {
210
209
211
210
// Locate installed apps.
212
211
[GILaunchServicesLocator setup ];
213
-
212
+
214
213
// Initialize user notification center
215
214
[[NSUserNotificationCenter defaultUserNotificationCenter ] setDelegate: self ];
216
215
217
216
// Register finder context menu services.
218
217
[NSApplication sharedApplication ].servicesProvider = [ServicesProvider new ];
219
-
218
+
220
219
// Notify user in case app was updated since last launch
221
220
NSString * currentVersion = [[NSBundle mainBundle ] objectForInfoDictionaryKey: @" CFBundleVersion" ];
222
221
NSString * lastVersion = [[NSUserDefaults standardUserDefaults ] objectForKey: kUserDefaultsKey_LastVersion ];
@@ -270,7 +269,7 @@ - (void)applicationDidFinishLaunching:(NSNotification*)notification {
270
269
271
270
// Load theme preference
272
271
[PreferencesThemeService applySelectedTheme ];
273
-
272
+
274
273
#if __ENABLE_SUDDEN_TERMINATION__
275
274
// Enable sudden termination
276
275
[[NSProcessInfo processInfo ] enableSuddenTermination ];
@@ -426,42 +425,42 @@ - (IBAction)newRepository:(id)sender {
426
425
}
427
426
428
427
- (void )_cloneRepositoryFromURLString : (NSString *)urlString {
429
- [self .cloneWindowController runModalForURL: urlString completion: ^(CloneWindowControllerResult * _Nonnull result) {
430
- if ( result. invalidRepository ) {
431
- [ NSApp presentError: MAKE_ERROR ( @" Invalid Git repository URL " )];
432
- return ;
433
- }
434
-
435
- if (result. emptyDirectoryPath ) {
436
- return ;
437
- }
438
-
439
- NSURL * url = result. repositoryURL ;
440
- NSString * path = result.directoryPath ;
441
- CloneMode cloneMode = result. recursive ? kCloneMode_Recursive : kCloneMode_Default ;
442
- NSError * error ;
443
-
444
- BOOL fileDoesntExistOrEvictedToTrash = ![[ NSFileManager defaultManager ] fileExistsAtPath: path followLastSymlink: NO ] || [[ NSFileManager defaultManager ] moveItemAtPathToTrash: path error: &error];
445
-
446
- if (!fileDoesntExistOrEvictedToTrash) {
447
- [ NSApp presentError: error];
448
- return ;
449
- }
450
-
451
- GCRepository* repository = [[GCRepository alloc ] initWithNewLocalRepository: path bare: NO error: &error];
452
- if (! repository) {
453
- [ NSApp presentError: error];
454
- return ;
455
- }
456
-
457
- if ([repository addRemoteWithName: @" origin " url: url error: &error]) {
458
- [ self _openRepositoryWithURL: [ NSURL fileURLWithPath: repository.workingDirectoryPath] withCloneMode: cloneMode windowModeID: NSNotFound ];
459
- } else {
460
- [ NSApp presentError: error];
461
- [[ NSFileManager defaultManager ] removeItemAtPath: path error: NULL ]; // Ignore errors
462
- }
463
-
464
- }];
428
+ [self .cloneWindowController runModalForURL: urlString
429
+ completion: ^(CloneWindowControllerResult* _Nonnull result) {
430
+ if (result. invalidRepository ) {
431
+ [ NSApp presentError: MAKE_ERROR ( @" Invalid Git repository URL " )] ;
432
+ return ;
433
+ }
434
+
435
+ if (result. emptyDirectoryPath ) {
436
+ return ;
437
+ }
438
+
439
+ NSURL * url = result.repositoryURL ;
440
+ NSString * path = result. directoryPath ;
441
+ CloneMode cloneMode = result. recursive ? kCloneMode_Recursive : kCloneMode_Default ;
442
+ NSError * error;
443
+
444
+ BOOL fileDoesntExistOrEvictedToTrash = ![[ NSFileManager defaultManager ] fileExistsAtPath: path followLastSymlink: NO ] || [[ NSFileManager defaultManager ] moveItemAtPathToTrash: path error: &error];
445
+
446
+ if (!fileDoesntExistOrEvictedToTrash) {
447
+ [ NSApp presentError: error] ;
448
+ return ;
449
+ }
450
+
451
+ GCRepository* repository = [[GCRepository alloc ] initWithNewLocalRepository: path bare: NO error: &error];
452
+ if (!repository) {
453
+ [ NSApp presentError: error] ;
454
+ return ;
455
+ }
456
+
457
+ if ([repository addRemoteWithName: @" origin " url: url error: &error]) {
458
+ [ self _openRepositoryWithURL: [ NSURL fileURLWithPath: repository.workingDirectoryPath] withCloneMode: cloneMode windowModeID: NSNotFound ];
459
+ } else {
460
+ [ NSApp presentError: error];
461
+ [[ NSFileManager defaultManager ] removeItemAtPath: path error: NULL ]; // Ignore errors
462
+ }
463
+ }];
465
464
}
466
465
467
466
- (IBAction )cloneRepository : (id )sender {
0 commit comments