Skip to content

Commit 27faaf8

Browse files
committed
Merge branch 'refs/heads/experimental'
2 parents c7636c4 + e08a24f commit 27faaf8

File tree

84 files changed

+4790
-518
lines changed

Some content is hidden

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

84 files changed

+4790
-518
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
build
22
build/revision
3+
._*
34
*.xcodeproj/
45
!*.xcodeproj/project.pbxproj
56
Nightly.app.zip

Commands/PBCommand.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// PBCommand.h
3+
// GitX
4+
//
5+
// Created by Tomasz Krasnyk on 10-11-06.
6+
// Copyright 2010 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import "PBGitRepository.h"
11+
12+
@interface PBCommand : NSObject {
13+
PBGitRepository *repository;
14+
15+
// for the user to see what it triggers
16+
NSString *displayName;
17+
// shown during command execution
18+
NSString *commandTitle;
19+
NSString *commandDescription;
20+
21+
NSMutableArray *parameters;
22+
BOOL canBeFired;
23+
}
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;
29+
30+
- (id) initWithDisplayName:(NSString *) aDisplayName parameters:(NSArray *) params repository:(PBGitRepository *) repo;
31+
32+
- (void) invoke;
33+
34+
- (NSArray *) allParameters;
35+
- (void) appendParameters:(NSArray *) params;
36+
@end

Commands/PBCommand.m

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//
2+
// PBCommand.m
3+
// GitX
4+
//
5+
// Created by Tomasz Krasnyk on 10-11-06.
6+
// Copyright 2010 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import "PBCommand.h"
10+
#import "PBRemoteProgressSheet.h"
11+
12+
@interface PBCommand()
13+
@property (nonatomic, retain) PBGitRepository *repository;
14+
@end
15+
16+
@implementation PBCommand
17+
@synthesize displayName;
18+
@synthesize commandDescription;
19+
@synthesize commandTitle;
20+
@synthesize repository;
21+
@synthesize canBeFired;
22+
23+
- (id) initWithDisplayName:(NSString *) aDisplayName parameters:(NSArray *) params {
24+
return [self initWithDisplayName:aDisplayName parameters:params repository:nil];
25+
}
26+
27+
- (id) initWithDisplayName:(NSString *) aDisplayName parameters:(NSArray *) params repository:(PBGitRepository *) repo {
28+
self = [super init];
29+
if (self != nil) {
30+
self.displayName = aDisplayName;
31+
parameters = [[NSMutableArray alloc] initWithArray:params];
32+
33+
// default values
34+
self.commandTitle = @"";
35+
self.commandDescription = @"";
36+
self.repository = repo;
37+
self.canBeFired = YES;
38+
}
39+
return self;
40+
}
41+
42+
43+
- (void) dealloc {
44+
[repository release];
45+
[commandDescription release];
46+
[commandTitle release];
47+
[parameters release];
48+
[displayName release];
49+
[super dealloc];
50+
}
51+
52+
- (NSArray *) allParameters {
53+
return parameters;
54+
}
55+
56+
- (void) appendParameters:(NSArray *) params {
57+
[parameters addObjectsFromArray:params];
58+
}
59+
60+
- (void) invoke {
61+
[PBRemoteProgressSheet beginRemoteProgressSheetForArguments:[self allParameters] title:self.commandTitle description:self.commandDescription inRepository:self.repository];
62+
}
63+
64+
@end

Commands/PBCommandFactory.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// PBCommandFactory.h
3+
// GitX
4+
//
5+
// Created by Tomasz Krasnyk on 10-11-06.
6+
// Copyright 2010 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import "PBGitRepository.h"
10+
11+
@protocol PBCommandFactory
12+
+ (NSArray *) commandsForObject:(NSObject *) object repository:(PBGitRepository *) repository;
13+
@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: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
#import "PBRevealWithFinderCommand.h"
13+
14+
15+
@implementation PBRemoteCommandFactory
16+
17+
+ (NSArray *) commandsForSubmodule:(PBGitSubmodule *) submodule inRepository:(PBGitRepository *) repository {
18+
NSMutableArray *commands = [[NSMutableArray alloc] init];
19+
20+
NSString *repoPath = [repository workingDirectory];
21+
NSString *path = [repoPath stringByAppendingPathComponent:[submodule path]];
22+
NSString *submodulePath = [submodule path];
23+
24+
if ([submodule submoduleState] == PBGitSubmoduleStateNotInitialized) {
25+
NSArray *params = [NSArray arrayWithObjects:@"submodule", @"init", submodulePath, nil];
26+
PBCommand *initCmd = [[PBCommand alloc] initWithDisplayName:@"Init" parameters:params repository:repository];
27+
initCmd.commandTitle = initCmd.displayName;
28+
initCmd.commandDescription = [NSString stringWithFormat:@"Initializing submodule %@", submodulePath];
29+
[commands addObject:initCmd];
30+
}
31+
32+
// update
33+
NSArray *params = [NSArray arrayWithObjects:@"submodule", @"update", submodulePath, nil];
34+
PBCommand *updateCmd = [[PBCommand alloc] initWithDisplayName:@"Update" parameters:params repository:repository];
35+
updateCmd.commandTitle = updateCmd.displayName;
36+
updateCmd.commandDescription = [NSString stringWithFormat:@"Updating submodule %@", submodulePath];
37+
[commands addObject:updateCmd];
38+
39+
if ([[submodule submodules] count] > 0) {
40+
// update recursively
41+
NSArray *recursiveUpdate = [NSArray arrayWithObjects:@"submodule", @"update", @"--recursive", submodulePath, nil];
42+
PBCommand *updateRecursively = [[PBCommand alloc] initWithDisplayName:@"Update recursively" parameters:recursiveUpdate repository:repository];
43+
updateRecursively.commandTitle = updateRecursively.displayName;
44+
updateRecursively.commandDescription = [NSString stringWithFormat:@"Updating submodule %@ (recursively)", submodulePath];
45+
[commands addObject:updateRecursively];
46+
}
47+
48+
if ([submodule submoduleState] != PBGitSubmoduleStateNotInitialized) {
49+
// open
50+
PBOpenDocumentCommand *command = [[PBOpenDocumentCommand alloc] initWithDocumentAbsolutePath:path];
51+
command.commandTitle = command.displayName;
52+
command.commandDescription = @"Opening document";
53+
[commands addObject:command];
54+
55+
[commands addObject:[[PBRevealWithFinderCommand alloc] initWithDocumentAbsolutePath:path]];
56+
}
57+
58+
return commands;
59+
}
60+
61+
+ (NSArray *) commandsForObject:(NSObject *) object repository:(PBGitRepository *) repository {
62+
if ([object isKindOfClass:[PBGitSubmodule class]]) {
63+
return [PBRemoteCommandFactory commandsForSubmodule:(id)object inRepository:repository];
64+
}
65+
return nil;
66+
}
67+
68+
@end

0 commit comments

Comments
 (0)