|
18 | 18 | #import "PBCloneRepositoryPanel.h"
|
19 | 19 | #import "Sparkle/SUUpdater.h"
|
20 | 20 | #import "AIURLAdditions.h"
|
| 21 | +#import "PBGitRepository.h" |
| 22 | + |
| 23 | +@interface ApplicationController () |
| 24 | +- (void) cleanUpRemotesOnError; |
| 25 | +@end |
| 26 | + |
21 | 27 |
|
22 | 28 | @implementation ApplicationController
|
23 | 29 |
|
@@ -72,7 +78,10 @@ - (void)applicationWillFinishLaunching:(NSNotification*)notification
|
72 | 78 |
|
73 | 79 | - (void)applicationDidFinishLaunching:(NSNotification*)notification
|
74 | 80 | {
|
75 |
| - [[SUUpdater sharedUpdater] setSendsSystemProfile:YES]; |
| 81 | + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getArguments:) name:@"GitCommandSent" object:Nil]; |
| 82 | + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cleanGitAfterErrorMessage:) name:@"ErrorMessageDidEnd" object:Nil]; |
| 83 | + |
| 84 | + [[SUUpdater sharedUpdater] setSendsSystemProfile:YES]; |
76 | 85 | [[SUUpdater sharedUpdater] setDelegate:self];
|
77 | 86 |
|
78 | 87 | if ([PBGitDefaults useAskPasswd]) {
|
@@ -392,6 +401,9 @@ - (void)applicationWillTerminate:(NSNotification *)aNotification
|
392 | 401 | [PBGitDefaults setPreviousDocumentPaths:paths];
|
393 | 402 | }
|
394 | 403 | }
|
| 404 | + |
| 405 | + [self removeObserver:self forKeyPath:@"ErrorMessageDidEnd"]; |
| 406 | + [self removeObserver:self forKeyPath:@"GitCommandSent"]; |
395 | 407 | }
|
396 | 408 |
|
397 | 409 | /**
|
@@ -443,5 +455,34 @@ - (IBAction)reportAProblem:(id)sender
|
443 | 455 | }
|
444 | 456 |
|
445 | 457 |
|
| 458 | +#pragma mark - Observer methods |
| 459 | + |
| 460 | +- (void)getArguments:(NSNotification*)notification |
| 461 | +{ |
| 462 | + notificationUserInfo = [notification userInfo]; |
| 463 | +} |
| 464 | + |
| 465 | + |
| 466 | +- (void)cleanGitAfterErrorMessage:(NSNotification*)notification |
| 467 | +{ |
| 468 | + // When adding a remote occurs an error the remote |
| 469 | + // will be set on git and has to be removed to clean the remotes list |
| 470 | + [self cleanUpRemotesOnError]; |
| 471 | + |
| 472 | + |
| 473 | + |
| 474 | +} |
| 475 | + |
| 476 | +#pragma mark - Extensions |
| 477 | +- (void) cleanUpRemotesOnError |
| 478 | +{ |
| 479 | + // check, if arguments was to add a remote |
| 480 | + if ( ([(NSString*)[notificationUserInfo valueForKey:@"Arg0"] compare:@"remote"] == NSOrderedSame) && |
| 481 | + ([(NSString*)[notificationUserInfo valueForKey:@"Arg1"] compare:@"add"] == NSOrderedSame) |
| 482 | + ) |
| 483 | + { |
| 484 | + [[notificationUserInfo valueForKey:@"Repository"] deleteRemoteWithName:[notificationUserInfo valueForKey:@"Arg3"]]; |
| 485 | + } |
| 486 | +} |
446 | 487 |
|
447 | 488 | @end
|
0 commit comments