Skip to content

Commit cc5c93c

Browse files
- stashes can be created with optional message
- added clearing all stashes - added possibility to ignore files with given extension - submodules are now showed - submodules can be opened
1 parent 896df91 commit cc5c93c

37 files changed

+1916
-178
lines changed

Commands/PBCommand.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,28 @@
77
//
88

99
#import <Foundation/Foundation.h>
10-
10+
#import "PBGitRepository.h"
1111

1212
@interface PBCommand : NSObject {
13+
PBGitRepository *repository;
14+
1315
// for the user to see what it triggers
1416
NSString *displayName;
1517
// shown during command execution
1618
NSString *commandTitle;
1719
NSString *commandDescription;
1820

19-
NSArray *parameters;
21+
NSMutableArray *parameters;
2022
}
23+
@property (nonatomic, retain, readonly) PBGitRepository *repository;
2124
@property (nonatomic, retain) NSString *commandTitle;
2225
@property (nonatomic, retain) NSString *commandDescription;
2326
@property (nonatomic, copy) NSString *displayName;
24-
@property (nonatomic, retain, readonly) NSArray *parameters;
2527

26-
- (id) initWithDisplayName:(NSString *) aDisplayName parameters:(NSArray *) params;
28+
- (id) initWithDisplayName:(NSString *) aDisplayName parameters:(NSArray *) params repository:(PBGitRepository *) repo;
29+
2730
- (void) invoke;
31+
32+
- (NSArray *) allParameters;
33+
- (void) appendParameters:(NSArray *) params;
2834
@end

Commands/PBCommand.m

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,56 @@
77
//
88

99
#import "PBCommand.h"
10+
#import "PBRemoteProgressSheet.h"
1011

12+
@interface PBCommand()
13+
@property (nonatomic, retain) PBGitRepository *repository;
14+
@end
1115

1216
@implementation PBCommand
1317
@synthesize displayName;
14-
@synthesize parameters;
1518
@synthesize commandDescription;
1619
@synthesize commandTitle;
20+
@synthesize repository;
1721

1822
- (id) initWithDisplayName:(NSString *) aDisplayName parameters:(NSArray *) params {
23+
return [self initWithDisplayName:aDisplayName parameters:params repository:nil];
24+
}
25+
26+
- (id) initWithDisplayName:(NSString *) aDisplayName parameters:(NSArray *) params repository:(PBGitRepository *) repo {
1927
self = [super init];
2028
if (self != nil) {
2129
self.displayName = aDisplayName;
22-
parameters = [params retain];
30+
parameters = [[NSMutableArray alloc] initWithArray:params];
2331

2432
// default values
2533
self.commandTitle = @"";
2634
self.commandDescription = @"";
35+
self.repository = repo;
2736
}
2837
return self;
2938
}
3039

3140

3241
- (void) dealloc {
42+
[repository release];
3343
[commandDescription release];
3444
[commandTitle release];
3545
[parameters release];
3646
[displayName release];
3747
[super dealloc];
3848
}
3949

50+
- (NSArray *) allParameters {
51+
return parameters;
52+
}
53+
54+
- (void) appendParameters:(NSArray *) params {
55+
[parameters addObjectsFromArray:params];
56+
}
57+
4058
- (void) invoke {
41-
NSLog(@"Warning: Empty/abstrac command has been fired!");
59+
[PBRemoteProgressSheet beginRemoteProgressSheetForArguments:[self allParameters] title:self.commandTitle description:self.commandDescription inRepository:self.repository];
4260
}
4361

4462
@end

Commands/PBCommandWithParameter.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// PBCommandWithParameter.h
3+
// GitX
4+
//
5+
// Created by Tomasz Krasnyk on 10-11-06.
6+
// Copyright 2010 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import <Cocoa/Cocoa.h>
10+
#import "PBCommand.h"
11+
12+
13+
@interface PBCommandWithParameter : PBCommand {
14+
PBCommand *command;
15+
NSString *parameterName;
16+
NSString *parameterDisplayName;
17+
}
18+
@property (nonatomic, retain, readonly) PBCommand *command;
19+
@property (nonatomic, retain, readonly) NSString *parameterName;
20+
@property (nonatomic, retain, readonly) NSString *parameterDisplayName;
21+
22+
- initWithCommand:(PBCommand *) command parameterName:(NSString *) param parameterDisplayName:(NSString *) paramDisplayName;
23+
@end

Commands/PBCommandWithParameter.m

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// PBCommandWithParameter.m
3+
// GitX
4+
//
5+
// Created by Tomasz Krasnyk on 10-11-06.
6+
// Copyright 2010 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import "PBCommandWithParameter.h"
10+
#import "PBArgumentPickerController.h"
11+
12+
13+
@implementation PBCommandWithParameter
14+
@synthesize command;
15+
@synthesize parameterName;
16+
@synthesize parameterDisplayName;
17+
18+
- initWithCommand:(PBCommand *) aCommand parameterName:(NSString *) param parameterDisplayName:(NSString *) paramDisplayName {
19+
if (self = [super initWithDisplayName:[aCommand displayName] parameters:nil repository:[aCommand repository]]) {
20+
command = [aCommand retain];
21+
parameterName = [param retain];
22+
parameterDisplayName = [paramDisplayName retain];
23+
}
24+
return self;
25+
}
26+
27+
- (void) dealloc {
28+
[command release];
29+
[parameterName release];
30+
[parameterDisplayName release];
31+
[super dealloc];
32+
}
33+
34+
35+
- (void) invoke {
36+
PBArgumentPickerController *controller = [[PBArgumentPickerController alloc] initWithCommandWithParameter:self];
37+
[NSApp beginSheet:[controller window] modalForWindow:[command.repository.windowController window] modalDelegate:controller didEndSelector:nil contextInfo:NULL];
38+
[controller release];
39+
}
40+
@end

Commands/PBOpenDocumentCommand.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// PBOpenDocumentCommand.h
3+
// GitX
4+
//
5+
// Created by Tomasz Krasnyk on 10-11-07.
6+
// Copyright 2010 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import <Cocoa/Cocoa.h>
10+
#import "PBCommand.h"
11+
12+
@interface PBOpenDocumentCommand : PBCommand {
13+
NSURL *documentURL;
14+
}
15+
16+
- (id) initWithDocumentAbsolutePath:(NSString *) path;
17+
@end

Commands/PBOpenDocumentCommand.m

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// PBOpenDocumentCommand.m
3+
// GitX
4+
//
5+
// Created by Tomasz Krasnyk on 10-11-07.
6+
// Copyright 2010 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import "PBOpenDocumentCommand.h"
10+
#import "PBRepositoryDocumentController.h"
11+
#import "PBGitRepository.h"
12+
13+
@implementation PBOpenDocumentCommand
14+
15+
- (id) initWithDocumentAbsolutePath:(NSString *) path {
16+
if (self = [super initWithDisplayName:@"Open" parameters:nil repository:nil]) {
17+
documentURL = [[NSURL alloc] initWithString:path];
18+
}
19+
return self;
20+
}
21+
22+
- (void) invoke {
23+
[[PBRepositoryDocumentController sharedDocumentController] documentForLocation:documentURL];
24+
}
25+
26+
@end

Commands/PBRemoteCommandFactory.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// PBRemoteCommandFactory.h
3+
// GitX
4+
//
5+
// Created by Tomasz Krasnyk on 10-11-07.
6+
// Copyright 2010 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import <Cocoa/Cocoa.h>
10+
#import "PBCommandFactory.h"
11+
12+
13+
@interface PBRemoteCommandFactory : NSObject<PBCommandFactory> {
14+
15+
}
16+
17+
@end

Commands/PBRemoteCommandFactory.m

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// PBRemoteCommandFactory.m
3+
// GitX
4+
//
5+
// Created by Tomasz Krasnyk on 10-11-07.
6+
// Copyright 2010 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import "PBRemoteCommandFactory.h"
10+
#import "PBOpenDocumentCommand.h"
11+
#import "PBGitSubmodule.h"
12+
13+
14+
@implementation PBRemoteCommandFactory
15+
16+
+ (NSArray *) commandsForSubmodule:(PBGitSubmodule *) submodule inRepository:(PBGitRepository *) repository {
17+
NSMutableArray *commands = [[NSMutableArray alloc] init];
18+
19+
NSString *repoPath = [repository workingDirectory];
20+
21+
NSString *path = [repoPath stringByAppendingPathComponent:[submodule path]];
22+
23+
PBOpenDocumentCommand *command = [[PBOpenDocumentCommand alloc] initWithDocumentAbsolutePath:path];
24+
command.commandTitle = command.displayName;
25+
command.commandDescription = @"Opening document";
26+
[commands addObject:command];
27+
28+
return commands;
29+
}
30+
31+
+ (NSArray *) commandsForObject:(NSObject *) object repository:(PBGitRepository *) repository {
32+
if ([object isKindOfClass:[PBGitSubmodule class]]) {
33+
return [PBRemoteCommandFactory commandsForSubmodule:(id)object inRepository:repository];
34+
}
35+
return nil;
36+
}
37+
38+
@end

Commands/PBStashCommand.h

Lines changed: 0 additions & 19 deletions
This file was deleted.

Commands/PBStashCommand.m

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)