Skip to content

Commit 35f06fc

Browse files
Update format-source.sh and format code (#672)
1 parent fd8dfc4 commit 35f06fc

24 files changed

+357
-306
lines changed

GitUp/Application/AboutWindowController.m

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ - (void)windowDidLoad {
2424
}
2525

2626
- (void)populateWithDataWhenUpdateIsPending:(BOOL)updatePending {
27-
NSString *version = nil;
28-
#if DEBUG
29-
version = @"DEBUG";
30-
#else
31-
if (updatePending) {
32-
version = NSLocalizedString(@"Update Pending", nil);
33-
} else {
34-
version = [NSString stringWithFormat:NSLocalizedString(@"Version %@ (%@)", nil), [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
35-
}
36-
#endif
37-
self.versionTextField.stringValue = version;
38-
self.copyrightTextField.stringValue = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSHumanReadableCopyright"];
27+
NSString* version = nil;
28+
#if DEBUG
29+
version = @"DEBUG";
30+
#else
31+
if (updatePending) {
32+
version = NSLocalizedString(@"Update Pending", nil);
33+
} else {
34+
version = [NSString stringWithFormat:NSLocalizedString(@"Version %@ (%@)", nil), [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
35+
}
36+
#endif
37+
self.versionTextField.stringValue = version;
38+
self.copyrightTextField.stringValue = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSHumanReadableCopyright"];
3939
}
4040

4141
@end

GitUp/Application/AppDelegate.m

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@
4343
#define kToolInstallPath @"/usr/local/bin/" kToolName
4444

4545
@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;
5050
@end
5151

5252
@implementation AppDelegate {
@@ -59,14 +59,14 @@ @implementation AppDelegate {
5959

6060
#pragma mark - Properties
6161

62-
- (AboutWindowController *)aboutWindowController {
62+
- (AboutWindowController*)aboutWindowController {
6363
if (!_aboutWindowController) {
6464
_aboutWindowController = [[AboutWindowController alloc] init];
6565
}
6666
return _aboutWindowController;
6767
}
6868

69-
- (CloneWindowController *)cloneWindowController {
69+
- (CloneWindowController*)cloneWindowController {
7070
if (!_cloneWindowController) {
7171
_cloneWindowController = [[CloneWindowController alloc] init];
7272
}
@@ -80,7 +80,7 @@ - (void)didChangeReleaseChannel:(BOOL)didChange {
8080
}
8181
}
8282

83-
- (PreferencesWindowController *)preferencesWindowController {
83+
- (PreferencesWindowController*)preferencesWindowController {
8484
if (!_preferencesWindowController) {
8585
_preferencesWindowController = [[PreferencesWindowController alloc] init];
8686
__weak typeof(self) weakSelf = self;
@@ -91,17 +91,16 @@ - (PreferencesWindowController *)preferencesWindowController {
9191
return _preferencesWindowController;
9292
}
9393

94-
- (WelcomeWindowController *)welcomeWindowController {
94+
- (WelcomeWindowController*)welcomeWindowController {
9595
if (!_welcomeWindowController) {
9696
_welcomeWindowController = [[WelcomeWindowController alloc] init];
97-
97+
9898
_welcomeWindowController.keyShouldShowWindow = kUserDefaultsKey_ShowWelcomeWindow;
99-
99+
100100
__weak typeof(self) weakSelf = self;
101-
_welcomeWindowController.openDocumentAtURL = ^(NSURL * _Nonnull url) {
101+
_welcomeWindowController.openDocumentAtURL = ^(NSURL* _Nonnull url) {
102102
[weakSelf _openDocumentAtURL:url];
103103
};
104-
105104
}
106105
return _welcomeWindowController;
107106
}
@@ -153,7 +152,7 @@ - (void)_openRepositoryWithURL:(NSURL*)url withCloneMode:(CloneMode)cloneMode wi
153152
}];
154153
}
155154

156-
- (void)_openDocumentAtURL:(NSURL *)url {
155+
- (void)_openDocumentAtURL:(NSURL*)url {
157156
[self _openRepositoryWithURL:url withCloneMode:kCloneMode_None windowModeID:NSNotFound];
158157
}
159158

@@ -210,13 +209,13 @@ - (void)applicationDidFinishLaunching:(NSNotification*)notification {
210209

211210
// Locate installed apps.
212211
[GILaunchServicesLocator setup];
213-
212+
214213
// Initialize user notification center
215214
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];
216215

217216
// Register finder context menu services.
218217
[NSApplication sharedApplication].servicesProvider = [ServicesProvider new];
219-
218+
220219
// Notify user in case app was updated since last launch
221220
NSString* currentVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
222221
NSString* lastVersion = [[NSUserDefaults standardUserDefaults] objectForKey:kUserDefaultsKey_LastVersion];
@@ -270,7 +269,7 @@ - (void)applicationDidFinishLaunching:(NSNotification*)notification {
270269

271270
// Load theme preference
272271
[PreferencesThemeService applySelectedTheme];
273-
272+
274273
#if __ENABLE_SUDDEN_TERMINATION__
275274
// Enable sudden termination
276275
[[NSProcessInfo processInfo] enableSuddenTermination];
@@ -426,42 +425,42 @@ - (IBAction)newRepository:(id)sender {
426425
}
427426

428427
- (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+
}];
465464
}
466465

467466
- (IBAction)cloneRepository:(id)sender {

GitUp/Application/AuthenticationWindowController.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#import <AppKit/AppKit.h>
99

10-
1110
NS_ASSUME_NONNULL_BEGIN
1211

1312
@class GCRepository;
@@ -16,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
1615

1716
// Repository
1817
- (void)repository:(GCRepository*)repository willStartTransferWithURL:(NSURL*)url;
19-
- (BOOL)repository:(GCRepository*)repository requiresPlainTextAuthenticationForURL:(NSURL*)url user:(NSString*)user username:(NSString * _Nullable * _Nonnull )username password:(NSString * _Nullable * _Nonnull)password;
18+
- (BOOL)repository:(GCRepository*)repository requiresPlainTextAuthenticationForURL:(NSURL*)url user:(NSString*)user username:(NSString* _Nullable* _Nonnull)username password:(NSString* _Nullable* _Nonnull)password;
2019
- (void)repository:(GCRepository*)repository didFinishTransferWithURL:(NSURL*)url success:(BOOL)success;
2120
@end
2221

GitUp/Application/AuthenticationWindowController.m

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
#import "KeychainAccessor.h"
1212

1313
@interface AuthenticationWindowControllerModel : NSObject
14-
@property (nonatomic, assign) BOOL useKeychain;
15-
@property (nonatomic, copy) NSURL *url;
16-
@property (nonatomic, copy) NSString *name;
17-
@property (nonatomic, copy) NSString *password;
14+
@property(nonatomic, assign) BOOL useKeychain;
15+
@property(nonatomic, copy) NSURL* url;
16+
@property(nonatomic, copy) NSString* name;
17+
@property(nonatomic, copy) NSString* password;
1818

19-
@property (nonatomic, assign, readonly) BOOL isValid;
19+
@property(nonatomic, assign, readonly) BOOL isValid;
2020
@end
2121

2222
@implementation AuthenticationWindowControllerModel
@@ -32,10 +32,10 @@ - (void)willStartTransfer {
3232
self.name = nil;
3333
self.password = nil;
3434
}
35-
- (void)didFinishTransferWithURL:(NSURL *)url success:(BOOL)success onResult:(void(^)(AuthenticationWindowControllerModel *model))onResult {
35+
- (void)didFinishTransferWithURL:(NSURL*)url success:(BOOL)success onResult:(void (^)(AuthenticationWindowControllerModel* model))onResult {
3636
if (onResult) {
3737
BOOL shouldPassModel = success && self.isValid;
38-
onResult( shouldPassModel ? self : nil );
38+
onResult(shouldPassModel ? self : nil);
3939
}
4040
self.url = nil;
4141
self.name = nil;
@@ -46,15 +46,15 @@ - (void)didFinishTransferWithURL:(NSURL *)url success:(BOOL)success onResult:(vo
4646
@interface AuthenticationWindowController ()
4747

4848
// Model
49-
@property (nonatomic, strong) AuthenticationWindowControllerModel *model;
49+
@property(nonatomic, strong) AuthenticationWindowControllerModel* model;
5050

5151
// Outlets
5252
@property(nonatomic, weak) IBOutlet NSTextField* urlTextField;
5353
@property(nonatomic, weak) IBOutlet NSTextField* nameTextField;
5454
@property(nonatomic, weak) IBOutlet NSSecureTextField* passwordTextField;
5555

5656
// Credentials
57-
@property (nonatomic, assign, readonly) BOOL credentialsExists;
57+
@property(nonatomic, assign, readonly) BOOL credentialsExists;
5858

5959
@end
6060

@@ -81,12 +81,12 @@ - (void)windowDidLoad {
8181

8282
#pragma mark - Actions
8383
- (IBAction)dismissModal:(id)sender {
84-
[NSApp stopModalWithCode:[(NSButton *)sender tag]];
84+
[NSApp stopModalWithCode:[(NSButton*)sender tag]];
8585
[self close];
8686
}
8787

8888
#pragma mark - FirstResponder
89-
- (NSResponder *)firstResponderWhenUsernameExists:(BOOL)usernameExists {
89+
- (NSResponder*)firstResponderWhenUsernameExists:(BOOL)usernameExists {
9090
return usernameExists ? self.passwordTextField : self.nameTextField;
9191
}
9292

@@ -117,34 +117,35 @@ - (BOOL)repository:(GCRepository*)repository requiresPlainTextAuthenticationForU
117117
// TODO: Add data to model and when window is appearing, we should set data from model.
118118
// We need two callbacks ( willPresentModal and didPresentModal ).
119119
self.model.url = url;
120-
120+
121121
self.model.name = *username ? *username : @"";
122122
self.model.password = @"";
123-
123+
124124
if (self.windowLoaded) {
125125
[self beforeRunInModal];
126-
}
127-
else {
126+
} else {
128127
// look at -windowDidLoad when window first time loaded.
129128
}
130-
129+
131130
if ([NSApp runModalForWindow:self.window] && self.credentialsExists) {
132131
self.model.name = self.nameTextField.stringValue;
133132
self.model.password = self.passwordTextField.stringValue;
134133
*username = self.model.name;
135134
*password = self.model.password;
136135
return YES;
137136
}
138-
137+
139138
return NO;
140139
}
141140

142141
- (void)repository:(GCRepository*)repository didFinishTransferWithURL:(NSURL*)url success:(BOOL)success {
143-
[self.model didFinishTransferWithURL:url success:success onResult:^(AuthenticationWindowControllerModel *model) {
144-
if (model) {
145-
[KeychainAccessor savePlainTextAuthenticationToKeychainForURL:url username:model.name password:model.password];
146-
}
147-
}];
142+
[self.model didFinishTransferWithURL:url
143+
success:success
144+
onResult:^(AuthenticationWindowControllerModel* model) {
145+
if (model) {
146+
[KeychainAccessor savePlainTextAuthenticationToKeychainForURL:url username:model.name password:model.password];
147+
}
148+
}];
148149
}
149150

150151
@end

GitUp/Application/CloneWindowController.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
NS_ASSUME_NONNULL_BEGIN
1111

1212
@interface CloneWindowControllerResult : NSObject
13-
@property (nonatomic, copy) NSURL *repositoryURL;
14-
@property (nonatomic, copy) NSString *directoryPath;
15-
@property (nonatomic) BOOL recursive;
13+
@property(nonatomic, copy) NSURL* repositoryURL;
14+
@property(nonatomic, copy) NSString* directoryPath;
15+
@property(nonatomic) BOOL recursive;
1616

17-
@property (nonatomic, readonly) BOOL invalidRepository;
18-
@property (nonatomic, readonly) BOOL emptyDirectoryPath;
17+
@property(nonatomic, readonly) BOOL invalidRepository;
18+
@property(nonatomic, readonly) BOOL emptyDirectoryPath;
1919
@end
2020

2121
@interface CloneWindowController : NSWindowController
22-
@property (nonatomic, copy) NSString *url;
23-
- (void)runModalForURL:(NSString *)url completion:(void(^)(CloneWindowControllerResult *result))completion;
22+
@property(nonatomic, copy) NSString* url;
23+
- (void)runModalForURL:(NSString*)url completion:(void (^)(CloneWindowControllerResult* result))completion;
2424
@end
2525

2626
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)