Skip to content

Commit b9476a1

Browse files
committed
Merge pull request #150 from Kyriakis/master
New Features and Bugfixes
2 parents 0d782b5 + 3c2de68 commit b9476a1

File tree

125 files changed

+5296
-5677
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+5296
-5677
lines changed

ApplicationController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//
88

99
#import <Cocoa/Cocoa.h>
10-
#import "PBGitRepository.h"
1110

1211
@class PBCloneRepositoryPanel;
1312

@@ -21,6 +20,7 @@
2120

2221
PBCloneRepositoryPanel *cloneRepositoryPanel;
2322

23+
NSDictionary *notificationUserInfo;
2424
}
2525

2626
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator;

ApplicationController.m

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
#import "PBCloneRepositoryPanel.h"
1919
#import "Sparkle/SUUpdater.h"
2020
#import "AIURLAdditions.h"
21+
#import "PBGitRepository.h"
22+
23+
@interface ApplicationController ()
24+
- (void) cleanUpRemotesOnError;
25+
@end
26+
2127

2228
@implementation ApplicationController
2329

@@ -72,7 +78,10 @@ - (void)applicationWillFinishLaunching:(NSNotification*)notification
7278

7379
- (void)applicationDidFinishLaunching:(NSNotification*)notification
7480
{
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];
7685
[[SUUpdater sharedUpdater] setDelegate:self];
7786

7887
if ([PBGitDefaults useAskPasswd]) {
@@ -245,7 +254,7 @@ - (NSManagedObjectModel *)managedObjectModel {
245254
return managedObjectModel;
246255
}
247256

248-
managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:nil] retain];
257+
managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil];
249258
return managedObjectModel;
250259
}
251260

@@ -392,6 +401,8 @@ - (void)applicationWillTerminate:(NSNotification *)aNotification
392401
[PBGitDefaults setPreviousDocumentPaths:paths];
393402
}
394403
}
404+
405+
[[NSNotificationCenter defaultCenter] removeObserver:self];
395406
}
396407

397408
/**
@@ -400,10 +411,9 @@ - (void)applicationWillTerminate:(NSNotification *)aNotification
400411

401412
- (void) dealloc {
402413

403-
[managedObjectContext release], managedObjectContext = nil;
404-
[persistentStoreCoordinator release], persistentStoreCoordinator = nil;
405-
[managedObjectModel release], managedObjectModel = nil;
406-
[super dealloc];
414+
managedObjectContext = nil;
415+
persistentStoreCoordinator = nil;
416+
managedObjectModel = nil;
407417
}
408418

409419

@@ -444,5 +454,35 @@ - (IBAction)reportAProblem:(id)sender
444454
}
445455

446456

457+
#pragma mark - Observer methods
458+
459+
- (void)getArguments:(NSNotification*)notification
460+
{
461+
notificationUserInfo = [notification userInfo];
462+
}
463+
464+
465+
- (void)cleanGitAfterErrorMessage:(NSNotification*)notification
466+
{
467+
// When adding a remote occurs an error the remote
468+
// will be set on git and has to be removed to clean the remotes list
469+
[self cleanUpRemotesOnError];
470+
471+
472+
473+
}
474+
475+
#pragma mark - Extensions
476+
- (void) cleanUpRemotesOnError
477+
{
478+
// check, if arguments was to add a remote
479+
if ( ([(NSString*)[notificationUserInfo valueForKey:@"Arg0"] compare:@"remote"] == NSOrderedSame) &&
480+
([(NSString*)[notificationUserInfo valueForKey:@"Arg1"] compare:@"add"] == NSOrderedSame)
481+
)
482+
{
483+
PBGitRef *remoteRef = [PBGitRef refFromString:[NSString stringWithFormat:@"%@%@", kGitXRemoteRefPrefix,[notificationUserInfo valueForKey:@"Arg3"]]];
484+
[[notificationUserInfo valueForKey:@"Repository"] deleteRemote:remoteRef];
485+
}
486+
}
447487

448488
@end

Commands/PBCommand.h

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,25 @@
77
//
88

99
#import <Foundation/Foundation.h>
10-
#import "PBGitRepository.h"
10+
11+
@class PBGitRepository;
1112

1213
@interface PBCommand : NSObject {
1314
PBGitRepository *repository;
14-
15-
// for the user to see what it triggers
1615
NSString *displayName;
17-
// shown during command execution
18-
NSString *commandTitle;
19-
NSString *commandDescription;
20-
2116
NSMutableArray *parameters;
2217
BOOL canBeFired;
2318
}
24-
@property (nonatomic) BOOL canBeFired;
25-
@property (nonatomic, retain, readonly) PBGitRepository *repository;
26-
@property (nonatomic, retain) NSString *commandTitle;
27-
@property (nonatomic, retain) NSString *commandDescription;
28-
@property (nonatomic, copy) NSString *displayName;
2919

30-
- (id) initWithDisplayName:(NSString *) aDisplayName parameters:(NSArray *) params repository:(PBGitRepository *) repo;
20+
@property BOOL canBeFired;
21+
@property (readonly) PBGitRepository *repository;
22+
@property (strong) NSString *commandTitle;
23+
@property (strong) NSString *commandDescription;
24+
@property (readonly) NSString *displayName;
3125

26+
- (id) initWithDisplayName:(NSString *) aDisplayName parameters:(NSArray *) params repository:(PBGitRepository *) repo;
3227
- (void) invoke;
33-
3428
- (NSArray *) allParameters;
3529
- (void) appendParameters:(NSArray *) params;
30+
3631
@end

Commands/PBCommand.m

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
#import "PBCommand.h"
1010
#import "PBRemoteProgressSheet.h"
1111

12-
@interface PBCommand()
13-
@property (nonatomic, retain) PBGitRepository *repository;
14-
@end
15-
1612
@implementation PBCommand
1713
@synthesize displayName;
1814
@synthesize commandDescription;
@@ -27,28 +23,16 @@ - (id) initWithDisplayName:(NSString *) aDisplayName parameters:(NSArray *) para
2723
- (id) initWithDisplayName:(NSString *) aDisplayName parameters:(NSArray *) params repository:(PBGitRepository *) repo {
2824
self = [super init];
2925
if (self != nil) {
30-
self.displayName = aDisplayName;
26+
displayName = aDisplayName;
3127
parameters = [[NSMutableArray alloc] initWithArray:params];
32-
33-
// default values
34-
self.commandTitle = @"";
35-
self.commandDescription = @"";
36-
self.repository = repo;
37-
self.canBeFired = YES;
28+
commandTitle = @"";
29+
commandDescription = @"";
30+
repository = repo;
31+
canBeFired = YES;
3832
}
3933
return self;
4034
}
4135

42-
43-
- (void) dealloc {
44-
[repository release];
45-
[commandDescription release];
46-
[commandTitle release];
47-
[parameters release];
48-
[displayName release];
49-
[super dealloc];
50-
}
51-
5236
- (NSArray *) allParameters {
5337
return parameters;
5438
}

Commands/PBCommandWithParameter.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
NSString *parameterName;
1616
NSString *parameterDisplayName;
1717
}
18-
@property (nonatomic, retain, readonly) PBCommand *command;
19-
@property (nonatomic, retain, readonly) NSString *parameterName;
20-
@property (nonatomic, retain, readonly) NSString *parameterDisplayName;
18+
@property (nonatomic, strong, readonly) PBCommand *command;
19+
@property (nonatomic, strong, readonly) NSString *parameterName;
20+
@property (nonatomic, strong, readonly) NSString *parameterDisplayName;
2121

2222
- initWithCommand:(PBCommand *) command parameterName:(NSString *) param parameterDisplayName:(NSString *) paramDisplayName;
2323
@end

Commands/PBCommandWithParameter.m

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
#import "PBCommandWithParameter.h"
1010
#import "PBArgumentPickerController.h"
11-
11+
#import "PBGitRepository.h"
12+
#import "PBGitWindowController.h"
1213

1314
@implementation PBCommandWithParameter
1415
@synthesize command;
@@ -17,24 +18,17 @@ @implementation PBCommandWithParameter
1718

1819
- initWithCommand:(PBCommand *) aCommand parameterName:(NSString *) param parameterDisplayName:(NSString *) paramDisplayName {
1920
if ((self = [super initWithDisplayName:[aCommand displayName] parameters:nil repository:[aCommand repository]])) {
20-
command = [aCommand retain];
21-
parameterName = [param retain];
22-
parameterDisplayName = [paramDisplayName retain];
21+
command = aCommand;
22+
parameterName = param;
23+
parameterDisplayName = paramDisplayName;
2324
}
2425
return self;
2526
}
2627

27-
- (void) dealloc {
28-
[command release];
29-
[parameterName release];
30-
[parameterDisplayName release];
31-
[super dealloc];
32-
}
3328

3429

3530
- (void) invoke {
3631
PBArgumentPickerController *controller = [[PBArgumentPickerController alloc] initWithCommandWithParameter:self];
3732
[NSApp beginSheet:[controller window] modalForWindow:[command.repository.windowController window] modalDelegate:controller didEndSelector:nil contextInfo:NULL];
38-
[controller release];
3933
}
4034
@end

Commands/PBRevealWithFinderCommand.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ @implementation PBRevealWithFinderCommand
1313

1414
- (id) initWithDocumentAbsolutePath:(NSString *) path {
1515
if (!path) {
16-
[self autorelease];
1716
return nil;
1817
}
1918

Commands/PBStashCommandFactory.m

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,15 @@ + (NSArray *) commandsForRef:(PBGitRef *) ref repository:(PBGitRepository *) rep
4747
command.commandDescription = @"Stashing local changes";
4848

4949
PBCommandWithParameter *cmd = [[PBCommandWithParameter alloc] initWithCommand:command parameterName:@"save" parameterDisplayName:@"Stash message (optional)"];
50-
[command release];
5150
[commands addObject:cmd];
52-
[cmd release];
5351

5452
command = [[PBCommand alloc] initWithDisplayName:@"Clear stashes" parameters:[NSArray arrayWithObjects:@"stash", @"clear", nil] repository:repository];
5553
command.commandTitle = command.displayName;
5654
command.commandDescription = @"Clearing stashes";
5755
[commands addObject:command];
58-
[command release];
5956
}
6057

61-
return [commands autorelease];
58+
return commands;
6259
}
6360

6461
+ (NSArray *) commandsForStash:(PBGitStash *) stash repository:(PBGitRepository *) repository {
@@ -82,7 +79,7 @@ + (NSArray *) commandsForStash:(PBGitStash *) stash repository:(PBGitRepository
8279
command.commandDescription = [NSString stringWithFormat:@"Dropping stash: '%@'", stash];
8380
[commands addObject:command];
8481

85-
return [commands autorelease];
82+
return commands;
8683
}
8784

8885
@end

Controller/GlobalProtocols.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// GlobalProtocols.h
3+
// GitX
4+
//
5+
// Created by Robert Kyriakis on 08.01.12.
6+
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@protocol Messages
12+
@required
13+
- (void)showMessageSheet:(NSString *)messageText infoText:(NSString *)infoText;
14+
- (void)showErrorSheet:(NSError *)error;
15+
@end

Controller/PBArgumentPickerController.m

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,11 @@ @implementation PBArgumentPickerController
1414

1515
- initWithCommandWithParameter:(PBCommandWithParameter *) aCommand {
1616
if ((self = [super initWithWindowNibName:@"PBArgumentPicker" owner:self])) {
17-
cmdWithParameter = [aCommand retain];
17+
cmdWithParameter = aCommand;
1818
}
1919
return self;
2020
}
2121

22-
- (void) dealloc {
23-
[cmdWithParameter release];
24-
25-
[super dealloc];
26-
}
2722

2823
- (void) awakeFromNib {
2924
NSString *stringToDisplay = [NSString stringWithFormat:@"%@:", [cmdWithParameter parameterDisplayName]];

0 commit comments

Comments
 (0)