|
8 | 8 |
|
9 | 9 | #import <Quartz/Quartz.h>
|
10 | 10 |
|
11 |
| -#import "PBGitCommit.h" |
| 11 | +#import "PBGitHistoryController.h" |
12 | 12 | #import "PBGitTree.h"
|
13 | 13 | #import "PBGitRef.h"
|
14 | 14 | #import "PBGitHistoryList.h"
|
15 | 15 | #import "PBGitRevSpecifier.h"
|
16 |
| -#import "PBGitHistoryController.h" |
17 | 16 | #import "PBWebHistoryController.h"
|
18 |
| -#import "PBGitGrapher.h" |
19 |
| -#import "PBGitRevisionCell.h" |
20 | 17 | #import "PBCommitList.h"
|
21 |
| -#import "PBCreateBranchSheet.h" |
22 |
| -#import "PBCreateTagSheet.h" |
23 |
| -#import "PBAddRemoteSheet.h" |
24 |
| -#import "PBGitSidebarController.h" |
25 | 18 | #import "PBGitGradientBarView.h"
|
26 | 19 | #import "PBDiffWindowController.h"
|
27 | 20 | #import "PBGitDefaults.h"
|
28 |
| -#import "PBGitRevList.h" |
29 | 21 | #import "PBHistorySearchController.h"
|
30 | 22 | #import "PBGitRepositoryWatcher.h"
|
31 | 23 | #import "PBQLTextView.h"
|
32 | 24 | #import "GLFileView.h"
|
33 | 25 | #import "GitXCommitCopier.h"
|
34 | 26 | #import "NSSplitView+GitX.h"
|
35 |
| -#import "PBRefMenuItem.h" |
36 |
| -#import "PBGitStash.h" |
37 | 27 |
|
38 | 28 | #define kHistorySelectedDetailIndexKey @"PBHistorySelectedDetailIndex"
|
39 | 29 | #define kHistoryDetailViewIndex 0
|
@@ -638,244 +628,6 @@ - (NSArray *)menuItemsForPaths:(NSArray *)paths
|
638 | 628 | return menuItems;
|
639 | 629 | }
|
640 | 630 |
|
641 |
| -#pragma mark Repository Methods |
642 |
| - |
643 |
| -- (id <PBGitRefish>)refishForSender:(id)sender refishTypes:(NSArray *)types |
644 |
| -{ |
645 |
| - return [self.windowController performSelector:@selector(refishForSender:refishTypes:) withObject:sender withObject:types]; |
646 |
| -} |
647 |
| - |
648 |
| -- (IBAction)pullRemote:(id)sender |
649 |
| -{ |
650 |
| - id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXBranchType]]; |
651 |
| - if (!refish || ![refish isKindOfClass:[PBGitRef class]]) |
652 |
| - return; |
653 |
| - |
654 |
| - [self.windowController performPullForBranch:refish remote:nil rebase:NO]; |
655 |
| -} |
656 |
| - |
657 |
| -- (IBAction)pushUpdatesToRemote:(id)sender |
658 |
| -{ |
659 |
| - id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXBranchType]]; |
660 |
| - if (!refish || ![refish isKindOfClass:[PBGitRef class]]) |
661 |
| - return; |
662 |
| - |
663 |
| - PBGitRef *remoteRef = [(PBGitRef *)refish remoteRef]; |
664 |
| - |
665 |
| - [self.windowController performPushForBranch:nil toRemote:remoteRef]; |
666 |
| -} |
667 |
| - |
668 |
| -- (IBAction)pushDefaultRemoteForRef:(id)sender |
669 |
| -{ |
670 |
| - id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXBranchType]]; |
671 |
| - if (!refish || ![refish isKindOfClass:[PBGitRef class]]) |
672 |
| - return; |
673 |
| - |
674 |
| - PBGitRef *ref = (PBGitRef *)refish; |
675 |
| - |
676 |
| - [self.windowController performPushForBranch:ref toRemote:nil]; |
677 |
| -} |
678 |
| - |
679 |
| -- (IBAction)pushToRemote:(id)sender |
680 |
| -{ |
681 |
| - id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXBranchType]]; |
682 |
| - if (!refish || ![refish isKindOfClass:[PBGitRef class]]) |
683 |
| - return; |
684 |
| - |
685 |
| - PBGitRef *ref = (PBGitRef *)refish; |
686 |
| - PBGitRef *remoteRef = ref.remoteRef; |
687 |
| - |
688 |
| - [self.windowController performPushForBranch:ref toRemote:remoteRef]; |
689 |
| -} |
690 |
| - |
691 |
| -- (IBAction)merge:(id)sender |
692 |
| -{ |
693 |
| - id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXBranchType, kGitXRemoteBranchType, kGitXCommitType, kGitXTagType]]; |
694 |
| - if (!refish) return; |
695 |
| - |
696 |
| - NSError *error = nil; |
697 |
| - BOOL success = [repository mergeWithRefish:refish error:&error]; |
698 |
| - if (!success) { |
699 |
| - [self.windowController showErrorSheet:error]; |
700 |
| - } |
701 |
| -} |
702 |
| - |
703 |
| -- (IBAction)checkout:(id)sender |
704 |
| -{ |
705 |
| - id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXBranchType, kGitXRemoteBranchType, kGitXCommitType, kGitXTagType]]; |
706 |
| - if (!refish) return; |
707 |
| - |
708 |
| - NSError *error = nil; |
709 |
| - BOOL success = [repository checkoutRefish:refish error:&error]; |
710 |
| - if (!success) { |
711 |
| - [self.windowController showErrorSheet:error]; |
712 |
| - } |
713 |
| -} |
714 |
| - |
715 |
| -- (IBAction)cherryPick:(id)sender |
716 |
| -{ |
717 |
| - id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXCommitType]]; |
718 |
| - if (!refish) return; |
719 |
| - |
720 |
| - NSError *error = nil; |
721 |
| - BOOL success = [repository cherryPickRefish:refish error:&error]; |
722 |
| - if (!success) { |
723 |
| - [self.windowController showErrorSheet:error]; |
724 |
| - } |
725 |
| -} |
726 |
| - |
727 |
| -- (IBAction)rebase:(id)sender |
728 |
| -{ |
729 |
| - id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXBranchType, kGitXRemoteBranchType]]; |
730 |
| - if (!refish) return; |
731 |
| - |
732 |
| - NSError *error = nil; |
733 |
| - BOOL success = [repository rebaseBranch:nil onRefish:refish error:&error]; |
734 |
| - if (!success) { |
735 |
| - [self.windowController showErrorSheet:error]; |
736 |
| - } |
737 |
| -} |
738 |
| - |
739 |
| -- (IBAction)rebaseHeadBranch:(id)sender |
740 |
| -{ |
741 |
| - id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXBranchType, kGitXRemoteBranchType]]; |
742 |
| - NSError *error = nil; |
743 |
| - BOOL success = [self.repository rebaseBranch:nil onRefish:refish error:&error]; |
744 |
| - if (!success) { |
745 |
| - [self.windowController showErrorSheet:error]; |
746 |
| - } |
747 |
| -} |
748 |
| - |
749 |
| -- (IBAction)showDeleteRefSheet:(id)sender |
750 |
| -{ |
751 |
| - id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXBranchType]]; |
752 |
| - if (!refish || ![refish isKindOfClass:[PBGitRef class]]) |
753 |
| - return; |
754 |
| - |
755 |
| - PBGitRef *ref = (PBGitRef *)refish; |
756 |
| - |
757 |
| - void (^performDelete)(void) = ^{ |
758 |
| - NSError *error = nil; |
759 |
| - BOOL success = [self.repository deleteRef:ref error:&error]; |
760 |
| - if (!success) { |
761 |
| - [self.windowController showErrorSheet:error]; |
762 |
| - } |
763 |
| - return; |
764 |
| - }; |
765 |
| - |
766 |
| - if ([PBGitDefaults isDialogWarningSuppressedForDialog:kDialogDeleteRef]) { |
767 |
| - performDelete(); |
768 |
| - return; |
769 |
| - } |
770 |
| - |
771 |
| - NSString *ref_desc = [NSString stringWithFormat:@"%@ '%@'", [ref refishType], [ref shortName]]; |
772 |
| - |
773 |
| - NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:@"Delete %@?", ref_desc] |
774 |
| - defaultButton:@"Delete" |
775 |
| - alternateButton:@"Cancel" |
776 |
| - otherButton:nil |
777 |
| - informativeTextWithFormat:@"Are you sure you want to remove the %@?", ref_desc]; |
778 |
| - [alert setShowsSuppressionButton:YES]; |
779 |
| - |
780 |
| - [alert beginSheetModalForWindow:self.windowController.window |
781 |
| - completionHandler:^(NSModalResponse returnCode) { |
782 |
| - if ([[alert suppressionButton] state] == NSOnState) |
783 |
| - [PBGitDefaults suppressDialogWarningForDialog:kDialogDeleteRef]; |
784 |
| - |
785 |
| - if (returnCode == NSModalResponseOK) { |
786 |
| - performDelete(); |
787 |
| - } |
788 |
| - }]; |
789 |
| -} |
790 |
| - |
791 |
| -- (IBAction)diffWithHEAD:(id)sender |
792 |
| -{ |
793 |
| - id <PBGitRefish> refish = [self refishForSender:sender refishTypes:nil]; |
794 |
| - if (!refish) |
795 |
| - return; |
796 |
| - |
797 |
| - PBGitCommit *commit = [self.repository commitForRef:refish]; |
798 |
| - |
799 |
| - NSString *diff = [self.repository performDiff:commit against:nil forFiles:nil]; |
800 |
| - |
801 |
| - [PBDiffWindowController showDiff:diff]; |
802 |
| -} |
803 |
| - |
804 |
| -- (IBAction)stashPop:(id)sender |
805 |
| -{ |
806 |
| - id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXStashType]]; |
807 |
| - PBGitStash *stash = [self.repository stashForRef:refish]; |
808 |
| - NSError *error = nil; |
809 |
| - BOOL success = [self.repository stashPop:stash error:&error]; |
810 |
| - |
811 |
| - if (!success) { |
812 |
| - [self.windowController showErrorSheet:error]; |
813 |
| - } else { |
814 |
| - [self.windowController showCommitView:sender]; |
815 |
| - } |
816 |
| -} |
817 |
| - |
818 |
| -- (IBAction)stashApply:(id)sender |
819 |
| -{ |
820 |
| - id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXStashType]]; |
821 |
| - PBGitStash *stash = [self.repository stashForRef:refish]; |
822 |
| - NSError *error = nil; |
823 |
| - BOOL success = [self.repository stashApply:stash error:&error]; |
824 |
| - |
825 |
| - if (!success) { |
826 |
| - [self.windowController showErrorSheet:error]; |
827 |
| - } else { |
828 |
| - [self.windowController showCommitView:sender]; |
829 |
| - } |
830 |
| -} |
831 |
| - |
832 |
| -- (IBAction)stashDrop:(id)sender |
833 |
| -{ |
834 |
| - id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXStashType]]; |
835 |
| - PBGitStash *stash = [self.repository stashForRef:refish]; |
836 |
| - NSError *error = nil; |
837 |
| - BOOL success = [self.repository stashDrop:stash error:&error]; |
838 |
| - |
839 |
| - if (!success) { |
840 |
| - [self.windowController showErrorSheet:error]; |
841 |
| - } else { |
842 |
| - [self.windowController showHistoryView:sender]; |
843 |
| - } |
844 |
| -} |
845 |
| - |
846 |
| -- (IBAction)stashViewDiff:(id)sender |
847 |
| -{ |
848 |
| - id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXStashType]]; |
849 |
| - PBGitStash *stash = [self.repository stashForRef:refish]; |
850 |
| - [PBDiffWindowController showDiffWindowWithFiles:nil fromCommit:stash.ancestorCommit diffCommit:stash.commit]; |
851 |
| -} |
852 |
| - |
853 |
| -- (IBAction)showTagInfoSheet:(id)sender |
854 |
| -{ |
855 |
| - id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXTagType]]; |
856 |
| - if (!refish) |
857 |
| - return; |
858 |
| - |
859 |
| - PBGitRef *ref = (PBGitRef *)refish; |
860 |
| - |
861 |
| - NSError *error = nil; |
862 |
| - NSString *tagName = [ref tagName]; |
863 |
| - NSString *tagRef = [@"refs/tags/" stringByAppendingString:tagName]; |
864 |
| - GTObject *object = [self.repository.gtRepo lookUpObjectByRevParse:tagRef error:&error]; |
865 |
| - if (!object) { |
866 |
| - NSLog(@"Couldn't look up ref %@:%@", tagRef, [error debugDescription]); |
867 |
| - return; |
868 |
| - } |
869 |
| - NSString *title = [NSString stringWithFormat:@"Info for tag: %@", tagName]; |
870 |
| - NSString *info = @""; |
871 |
| - if ([object isKindOfClass:[GTTag class]]) { |
872 |
| - GTTag *tag = (GTTag*)object; |
873 |
| - info = tag.message; |
874 |
| - } |
875 |
| - |
876 |
| - [self.windowController showMessageSheet:title infoText:info]; |
877 |
| -} |
878 |
| - |
879 | 631 | #pragma mark -
|
880 | 632 | #pragma mark Quick Look
|
881 | 633 |
|
|
0 commit comments