Skip to content

Commit 2e63424

Browse files
committed
Rewire stash actions
1 parent cbcba80 commit 2e63424

File tree

2 files changed

+50
-47
lines changed

2 files changed

+50
-47
lines changed

Classes/Controllers/PBGitHistoryController.m

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#import "GitXCommitCopier.h"
3434
#import "NSSplitView+GitX.h"
3535
#import "PBRefMenuItem.h"
36+
#import "PBGitStash.h"
3637

3738
#define kHistorySelectedDetailIndexKey @"PBHistorySelectedDetailIndex"
3839
#define kHistoryDetailViewIndex 0
@@ -826,6 +827,55 @@ - (IBAction)diffWithHEAD:(id)sender
826827
[PBDiffWindowController showDiff:diff];
827828
}
828829

830+
- (IBAction)stashPop:(id)sender
831+
{
832+
id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXStashType]];
833+
PBGitStash *stash = [self.repository stashForRef:refish];
834+
NSError *error = nil;
835+
BOOL success = [self.repository stashPop:stash error:&error];
836+
837+
if (!success) {
838+
[self.windowController showErrorSheet:error];
839+
} else {
840+
[self.windowController showCommitView:sender];
841+
}
842+
}
843+
844+
- (IBAction)stashApply:(id)sender
845+
{
846+
id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXStashType]];
847+
PBGitStash *stash = [self.repository stashForRef:refish];
848+
NSError *error = nil;
849+
BOOL success = [self.repository stashApply:stash error:&error];
850+
851+
if (!success) {
852+
[self.windowController showErrorSheet:error];
853+
} else {
854+
[self.windowController showCommitView:sender];
855+
}
856+
}
857+
858+
- (IBAction)stashDrop:(id)sender
859+
{
860+
id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXStashType]];
861+
PBGitStash *stash = [self.repository stashForRef:refish];
862+
NSError *error = nil;
863+
BOOL success = [self.repository stashDrop:stash error:&error];
864+
865+
if (!success) {
866+
[self.windowController showErrorSheet:error];
867+
} else {
868+
[self.windowController showHistoryView:sender];
869+
}
870+
}
871+
872+
- (IBAction)stashViewDiff:(id)sender
873+
{
874+
id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXStashType]];
875+
PBGitStash *stash = [self.repository stashForRef:refish];
876+
[PBDiffWindowController showDiffWindowWithFiles:nil fromCommit:stash.ancestorCommit diffCommit:stash.commit];
877+
}
878+
829879
#pragma mark -
830880
#pragma mark Quick Look
831881

Classes/Controllers/PBRefController.m

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -26,53 +26,6 @@ - (void)awakeFromNib
2626
[commitList registerForDraggedTypes:[NSArray arrayWithObject:@"PBGitRef"]];
2727
}
2828

29-
#pragma mark Stash
30-
31-
- (IBAction) stashPop:(PBRefMenuItem *)sender
32-
{
33-
PBGitStash *stash = [historyController.repository stashForRef:[sender refishs].firstObject];
34-
NSError *error = nil;
35-
BOOL success = [historyController.repository stashPop:stash error:&error];
36-
37-
if (!success) {
38-
[historyController.windowController showErrorSheet:error];
39-
} else {
40-
[historyController.windowController showCommitView:sender];
41-
}
42-
}
43-
44-
- (IBAction) stashApply:(PBRefMenuItem *)sender
45-
{
46-
PBGitStash *stash = [historyController.repository stashForRef:[sender refishs].firstObject];
47-
NSError *error = nil;
48-
BOOL success = [historyController.repository stashApply:stash error:&error];
49-
50-
if (!success) {
51-
[historyController.windowController showErrorSheet:error];
52-
} else {
53-
[historyController.windowController showCommitView:sender];
54-
}
55-
}
56-
57-
- (IBAction) stashDrop:(PBRefMenuItem *)sender
58-
{
59-
PBGitStash * stash = [historyController.repository stashForRef:[sender refishs].firstObject];
60-
NSError *error = nil;
61-
BOOL success = [historyController.repository stashDrop:stash error:&error];
62-
63-
if (!success) {
64-
[historyController.windowController showErrorSheet:error];
65-
} else {
66-
[historyController.windowController showHistoryView:sender];
67-
}
68-
}
69-
70-
- (IBAction) stashViewDiff:(PBRefMenuItem *)sender
71-
{
72-
PBGitStash * stash = [historyController.repository stashForRef:sender.refishs.firstObject];
73-
[PBDiffWindowController showDiffWindowWithFiles:nil fromCommit:stash.ancestorCommit diffCommit:stash.commit];
74-
}
75-
7629
#pragma mark Tags
7730

7831
- (IBAction) showTagInfoSheet:(PBRefMenuItem *)sender

0 commit comments

Comments
 (0)