Skip to content

Commit 0a3b600

Browse files
Stashes are shown on in Side controlle
1 parent 59c4983 commit 0a3b600

20 files changed

+565
-11
lines changed

Commands/PBCommand.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
11+
12+
@interface PBCommand : NSObject {
13+
// for the user to see what it triggers
14+
NSString *displayName;
15+
// shown during command execution
16+
NSString *commandTitle;
17+
NSString *commandDescription;
18+
19+
NSArray *parameters;
20+
}
21+
@property (nonatomic, retain) NSString *commandTitle;
22+
@property (nonatomic, retain) NSString *commandDescription;
23+
@property (nonatomic, copy) NSString *displayName;
24+
@property (nonatomic, retain, readonly) NSArray *parameters;
25+
26+
- (id) initWithDisplayName:(NSString *) aDisplayName parameters:(NSArray *) params;
27+
- (void) invoke;
28+
@end

Commands/PBCommand.m

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
11+
12+
@implementation PBCommand
13+
@synthesize displayName;
14+
@synthesize parameters;
15+
@synthesize commandDescription;
16+
@synthesize commandTitle;
17+
18+
- (id) initWithDisplayName:(NSString *) aDisplayName parameters:(NSArray *) params {
19+
self = [super init];
20+
if (self != nil) {
21+
self.displayName = aDisplayName;
22+
parameters = [params retain];
23+
24+
// default values
25+
self.commandTitle = @"";
26+
self.commandDescription = @"";
27+
}
28+
return self;
29+
}
30+
31+
32+
- (void) dealloc {
33+
[commandDescription release];
34+
[commandTitle release];
35+
[parameters release];
36+
[displayName release];
37+
[super dealloc];
38+
}
39+
40+
- (void) invoke {
41+
NSLog(@"Warning: Empty/abstrac command has been fired!");
42+
}
43+
44+
@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/PBStashCommand.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// PBStashCommand.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 "PBCommand.h"
11+
#import "PBGitRepository.h"
12+
13+
@interface PBStashCommand : PBCommand {
14+
PBGitRepository *repository;
15+
NSArray *arguments;
16+
}
17+
18+
- initWithDisplayName:(NSString *) aDisplayName arguments:(NSArray *) args repository:(PBGitRepository *) repo;
19+
@end

Commands/PBStashCommand.m

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//
2+
// PBStashCommand.m
3+
// GitX
4+
//
5+
// Created by Tomasz Krasnyk on 10-11-06.
6+
// Copyright 2010 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import "PBStashCommand.h"
10+
#import "PBRemoteProgressSheet.h"
11+
12+
@interface PBStashCommand()
13+
@property (nonatomic, retain) PBGitRepository *repository;
14+
@property (nonatomic, retain) NSArray *arguments;
15+
@end
16+
17+
18+
@implementation PBStashCommand
19+
@synthesize repository;
20+
@synthesize arguments;
21+
22+
- initWithDisplayName:(NSString *) aDisplayName arguments:(NSArray *) args repository:(PBGitRepository *) repo {
23+
if (self = [super initWithDisplayName:aDisplayName parameters:[NSArray arrayWithObject:@"stash"]]) {
24+
self.arguments = args;
25+
self.repository = repo;
26+
}
27+
return self;
28+
}
29+
30+
- (void) dealloc {
31+
[parameters release];
32+
[repository release];
33+
[super dealloc];
34+
}
35+
36+
37+
- (void) invoke {
38+
NSMutableArray *args = [[NSMutableArray alloc] initWithArray:super.parameters];
39+
[args addObjectsFromArray:self.arguments];
40+
[PBRemoteProgressSheet beginRemoteProgressSheetForArguments:args title:self.commandTitle description:self.commandDescription inRepository:self.repository];
41+
[args release];
42+
}
43+
44+
@end

Commands/PBStashCommandFactory.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// PBStashCommandFactory.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 "PBCommandFactory.h"
11+
12+
@interface PBStashCommandFactory : NSObject<PBCommandFactory> {
13+
14+
}
15+
16+
@end

Commands/PBStashCommandFactory.m

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// PBStashCommandFactory.m
3+
// GitX
4+
//
5+
// Created by Tomasz Krasnyk on 10-11-06.
6+
// Copyright 2010 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import "PBStashCommandFactory.h"
10+
#import "PBStashCommand.h"
11+
12+
// model
13+
#import "PBGitStash.h"
14+
15+
@implementation PBStashCommandFactory
16+
17+
+ (NSArray *) commandsForObject:(NSObject *) object repository:(PBGitRepository *) repository {
18+
if (![object isKindOfClass:[PBGitStash class]]) {
19+
return nil;
20+
}
21+
PBGitStash *stash = (PBGitStash *) object;
22+
NSMutableArray *commands = [[NSMutableArray alloc] init];
23+
24+
NSArray *args = [NSArray arrayWithObjects:@"apply", [stash name], nil];
25+
PBStashCommand *command = [[PBStashCommand alloc] initWithDisplayName:@"Apply" arguments:args repository:repository];
26+
command.commandTitle = command.displayName;
27+
command.commandDescription = [NSString stringWithFormat:@"Applying stash: '%@'", stash];
28+
[commands addObject:command];
29+
30+
args = [NSArray arrayWithObjects:@"pop", [stash name], nil];
31+
command = [[PBStashCommand alloc] initWithDisplayName:@"Pop" arguments:args repository:repository];
32+
command.commandTitle = command.displayName;
33+
command.commandDescription = [NSString stringWithFormat:@"Poping stash: '%@'", stash];
34+
[commands addObject:command];
35+
36+
args = [NSArray arrayWithObjects:@"drop", [stash name], nil];
37+
command = [[PBStashCommand alloc] initWithDisplayName:@"Drop" arguments:args repository:repository];
38+
command.commandTitle = command.displayName;
39+
command.commandDescription = [NSString stringWithFormat:@"Dropping stash: '%@'", stash];
40+
[commands addObject:command];
41+
42+
43+
return [commands autorelease];
44+
}
45+
46+
@end

GitX.xcodeproj/project.pbxproj

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
02B41A5E123E307200DFC531 /* PBCommitHookFailedSheet.m in Sources */ = {isa = PBXBuildFile; fileRef = 02B41A5D123E307200DFC531 /* PBCommitHookFailedSheet.m */; };
2525
02B41A60123E307F00DFC531 /* PBCommitHookFailedSheet.xib in Resources */ = {isa = PBXBuildFile; fileRef = 02B41A5F123E307F00DFC531 /* PBCommitHookFailedSheet.xib */; };
2626
056438B70ED0C40B00985397 /* DetailViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 056438B60ED0C40B00985397 /* DetailViewTemplate.png */; };
27+
21230CB11284B26A0046E5A1 /* PBGitSVStashItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 21230CB01284B26A0046E5A1 /* PBGitSVStashItem.m */; };
28+
21230D351284C5080046E5A1 /* PBGitStash.m in Sources */ = {isa = PBXBuildFile; fileRef = 21230D341284C5080046E5A1 /* PBGitStash.m */; };
29+
21230D821284D1CC0046E5A1 /* stash-icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 21230D811284D1CC0046E5A1 /* stash-icon.png */; };
30+
21230D9C128552720046E5A1 /* PBCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 21230D9B128552720046E5A1 /* PBCommand.m */; };
31+
21230D9F128552FA0046E5A1 /* PBStashCommandFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 21230D9E128552FA0046E5A1 /* PBStashCommandFactory.m */; };
32+
21230DAA1285550B0046E5A1 /* PBCommandMenuItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 21230DA91285550B0046E5A1 /* PBCommandMenuItem.m */; };
33+
21230DEE12855A990046E5A1 /* PBStashCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 21230DED12855A990046E5A1 /* PBStashCommand.m */; };
2734
3BC07F4C0ED5A5C5009A7768 /* HistoryViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 3BC07F4A0ED5A5C5009A7768 /* HistoryViewTemplate.png */; };
2835
3BC07F4D0ED5A5C5009A7768 /* CommitViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 3BC07F4B0ED5A5C5009A7768 /* CommitViewTemplate.png */; };
2936
47DBDB580E94EDE700671A1E /* DBPrefsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 47DBDB570E94EDE700671A1E /* DBPrefsWindowController.m */; };
@@ -245,6 +252,21 @@
245252
056438B60ED0C40B00985397 /* DetailViewTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = DetailViewTemplate.png; path = Images/DetailViewTemplate.png; sourceTree = "<group>"; };
246253
089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
247254
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
255+
21230CAF1284B26A0046E5A1 /* PBGitSVStashItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitSVStashItem.h; sourceTree = "<group>"; };
256+
21230CB01284B26A0046E5A1 /* PBGitSVStashItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitSVStashItem.m; sourceTree = "<group>"; };
257+
21230D331284C5080046E5A1 /* PBGitStash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitStash.h; sourceTree = "<group>"; };
258+
21230D341284C5080046E5A1 /* PBGitStash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitStash.m; sourceTree = "<group>"; };
259+
21230D4D1284C92E0046E5A1 /* PBPresentable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBPresentable.h; sourceTree = "<group>"; };
260+
21230D811284D1CC0046E5A1 /* stash-icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "stash-icon.png"; sourceTree = "<group>"; };
261+
21230D9A128552720046E5A1 /* PBCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBCommand.h; sourceTree = "<group>"; };
262+
21230D9B128552720046E5A1 /* PBCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBCommand.m; sourceTree = "<group>"; };
263+
21230D9D128552FA0046E5A1 /* PBStashCommandFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBStashCommandFactory.h; sourceTree = "<group>"; };
264+
21230D9E128552FA0046E5A1 /* PBStashCommandFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBStashCommandFactory.m; sourceTree = "<group>"; };
265+
21230DA0128553120046E5A1 /* PBCommandFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBCommandFactory.h; sourceTree = "<group>"; };
266+
21230DA81285550B0046E5A1 /* PBCommandMenuItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBCommandMenuItem.h; sourceTree = "<group>"; };
267+
21230DA91285550B0046E5A1 /* PBCommandMenuItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBCommandMenuItem.m; sourceTree = "<group>"; };
268+
21230DEC12855A990046E5A1 /* PBStashCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBStashCommand.h; sourceTree = "<group>"; };
269+
21230DED12855A990046E5A1 /* PBStashCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBStashCommand.m; sourceTree = "<group>"; };
248270
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
249271
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
250272
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
@@ -527,6 +549,8 @@
527549
080E96DDFE201D6D7F000001 /* Classes */ = {
528550
isa = PBXGroup;
529551
children = (
552+
21230D991285524C0046E5A1 /* Commands */,
553+
21230D321284C4F10046E5A1 /* Model */,
530554
);
531555
name = Classes;
532556
sourceTree = "<group>";
@@ -567,6 +591,30 @@
567591
name = Products;
568592
sourceTree = "<group>";
569593
};
594+
21230D321284C4F10046E5A1 /* Model */ = {
595+
isa = PBXGroup;
596+
children = (
597+
21230D331284C5080046E5A1 /* PBGitStash.h */,
598+
21230D341284C5080046E5A1 /* PBGitStash.m */,
599+
21230D4D1284C92E0046E5A1 /* PBPresentable.h */,
600+
);
601+
path = Model;
602+
sourceTree = "<group>";
603+
};
604+
21230D991285524C0046E5A1 /* Commands */ = {
605+
isa = PBXGroup;
606+
children = (
607+
21230D9A128552720046E5A1 /* PBCommand.h */,
608+
21230D9B128552720046E5A1 /* PBCommand.m */,
609+
21230DEC12855A990046E5A1 /* PBStashCommand.h */,
610+
21230DED12855A990046E5A1 /* PBStashCommand.m */,
611+
21230D9D128552FA0046E5A1 /* PBStashCommandFactory.h */,
612+
21230D9E128552FA0046E5A1 /* PBStashCommandFactory.m */,
613+
21230DA0128553120046E5A1 /* PBCommandFactory.h */,
614+
);
615+
path = Commands;
616+
sourceTree = "<group>";
617+
};
570618
29B97314FDCFA39411CA2CEA /* GitTest */ = {
571619
isa = PBXGroup;
572620
children = (
@@ -612,6 +660,7 @@
612660
F56ADDD70ED19F9E002AC78F /* AddBranchTemplate.png */,
613661
F56ADDD80ED19F9E002AC78F /* AddLabelTemplate.png */,
614662
056438B60ED0C40B00985397 /* DetailViewTemplate.png */,
663+
21230D811284D1CC0046E5A1 /* stash-icon.png */,
615664
F57240BA0E9678EA00D8EE66 /* deleted_file.png */,
616665
F5E92A1A0E88550E00056E75 /* empty_file.png */,
617666
32CA4F630368D1EE00C91783 /* GitX_Prefix.pch */,
@@ -744,6 +793,8 @@
744793
D8FDDA63114335E8005647F6 /* PBGitSVRemoteBranchItem.m */,
745794
D8FDDA68114335E8005647F6 /* PBGitSVTagItem.h */,
746795
D8FDDA69114335E8005647F6 /* PBGitSVTagItem.m */,
796+
21230CAF1284B26A0046E5A1 /* PBGitSVStashItem.h */,
797+
21230CB01284B26A0046E5A1 /* PBGitSVStashItem.m */,
747798
D8FDDA60114335E8005647F6 /* PBGitSVOtherRevItem.h */,
748799
D8FDDA61114335E8005647F6 /* PBGitSVOtherRevItem.m */,
749800
D8FDDA5E114335E8005647F6 /* PBGitSVFolderItem.h */,
@@ -938,6 +989,8 @@
938989
F5FC43C30EBD050800191D80 /* PBRefContextDelegate.h */,
939990
F5FC43FC0EBD08EE00191D80 /* PBRefMenuItem.h */,
940991
F5FC43FD0EBD08EE00191D80 /* PBRefMenuItem.m */,
992+
21230DA81285550B0046E5A1 /* PBCommandMenuItem.h */,
993+
21230DA91285550B0046E5A1 /* PBCommandMenuItem.m */,
941994
);
942995
name = History;
943996
sourceTree = "<group>";
@@ -1114,7 +1167,14 @@
11141167
isa = PBXProject;
11151168
buildConfigurationList = 26FC0A880875C7B200E6366F /* Build configuration list for PBXProject "GitX" */;
11161169
compatibilityVersion = "Xcode 3.1";
1170+
developmentRegion = English;
11171171
hasScannedForEncodings = 1;
1172+
knownRegions = (
1173+
English,
1174+
Japanese,
1175+
French,
1176+
German,
1177+
);
11181178
mainGroup = 29B97314FDCFA39411CA2CEA /* GitTest */;
11191179
projectDirPath = "";
11201180
projectRoot = "";
@@ -1181,6 +1241,7 @@
11811241
D8F01C4B12182F19007F729F /* GitX.sdef in Resources */,
11821242
D8F4AB7912298CE200D6D53C /* rewindImage.pdf in Resources */,
11831243
02B41A60123E307F00DFC531 /* PBCommitHookFailedSheet.xib in Resources */,
1244+
21230D821284D1CC0046E5A1 /* stash-icon.png in Resources */,
11841245
);
11851246
runOnlyForDeploymentPostprocessing = 0;
11861247
};
@@ -1331,6 +1392,12 @@
13311392
D8B4DC571220D1E4004166D6 /* PBHistorySearchController.m in Sources */,
13321393
D8712A00122B14EC00012334 /* GitXTextFieldCell.m in Sources */,
13331394
02B41A5E123E307200DFC531 /* PBCommitHookFailedSheet.m in Sources */,
1395+
21230CB11284B26A0046E5A1 /* PBGitSVStashItem.m in Sources */,
1396+
21230D351284C5080046E5A1 /* PBGitStash.m in Sources */,
1397+
21230D9C128552720046E5A1 /* PBCommand.m in Sources */,
1398+
21230D9F128552FA0046E5A1 /* PBStashCommandFactory.m in Sources */,
1399+
21230DAA1285550B0046E5A1 /* PBCommandMenuItem.m in Sources */,
1400+
21230DEE12855A990046E5A1 /* PBStashCommand.m in Sources */,
13341401
);
13351402
runOnlyForDeploymentPostprocessing = 0;
13361403
};

Model/PBGitStash.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// PBGitStash.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 "PBPresentable.h"
11+
12+
@interface PBGitStash : NSObject<PBPresentable> {
13+
NSString *stashRawString;
14+
15+
NSString *stashSourceMessage;
16+
NSString *name;
17+
NSString *message;
18+
}
19+
@property (nonatomic, retain, readonly) NSString *name;
20+
@property (nonatomic, retain, readonly) NSString *message;
21+
@property (nonatomic, retain, readonly) NSString *stashSourceMessage;
22+
@property (nonatomic, retain, readonly) NSString *stashRawString;
23+
24+
- initWithRawStashLine:(NSString *) stashLineFromStashListOutput;
25+
@end

0 commit comments

Comments
 (0)