Skip to content

Commit e733b7f

Browse files
committed
Merge branch 'master' into publish-cli
2 parents 08af557 + 50afd29 commit e733b7f

File tree

84 files changed

+1181
-1154
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

+1181
-1154
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@
1010
[submodule "MGScopeBar"]
1111
path = External/MGScopeBar
1212
url = https://github.com/rowanj/MGScopeBar.git
13+
[submodule "External/MAKVONotificationCenter"]
14+
path = External/MAKVONotificationCenter
15+
url = https://github.com/mikeash/MAKVONotificationCenter

Classes/Controllers/PBGitCommitController.m

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ - (void)awakeFromNib
7676
commitMessageView.repository = self.repository;
7777
commitMessageView.delegate = self;
7878

79-
[commitMessageView setTypingAttributes:[NSDictionary dictionaryWithObject:[NSFont fontWithName:@"Menlo" size:12.0] forKey:NSFontAttributeName]];
80-
79+
NSMutableDictionary *attrs = commitMessageView.typingAttributes.mutableCopy;
80+
attrs[NSFontAttributeName] = [NSFont fontWithName:@"Menlo" size:12.0];
81+
commitMessageView.typingAttributes = attrs;
82+
8183
[unstagedFilesController setFilterPredicate:[NSPredicate predicateWithFormat:@"hasUnstagedChanges == 1"]];
8284
[stagedFilesController setFilterPredicate:[NSPredicate predicateWithFormat:@"hasStagedChanges == 1"]];
8385
[trackedFilesController setFilterPredicate:[NSPredicate predicateWithFormat:@"status > 0"]];
@@ -573,7 +575,7 @@ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem
573575
}
574576
return filesForStaging.count > 0 && canDiscardAnyFileIn(filesForStaging);
575577
}
576-
else if (menuItem.action == @selector(trashFiles:)) {
578+
else if (menuItem.action == @selector(moveToTrash:)) {
577579
if (isInContextualMenu) {
578580
menuItem.title = PBLocalizedStringForArray(filesForStaging,
579581
NSLocalizedString(@"Move “%@” to Trash", @"Move to Trash menu item (single file with name)"),
@@ -643,14 +645,14 @@ - (void)tableView:(NSTableView*)tableView willDisplayCell:(id)cell forTableColum
643645

644646
- (void) didDoubleClickOnTable:(NSTableView *) tableView
645647
{
646-
NSArrayController *controller = [tableView tag] == 0 ? unstagedFilesController : stagedFilesController;
648+
NSArrayController *controller = (tableView == unstagedTable ? unstagedFilesController : stagedFilesController);
647649

648650
NSIndexSet *selectionIndexes = [tableView selectedRowIndexes];
649651
NSArray *files = [[controller arrangedObjects] objectsAtIndexes:selectionIndexes];
650-
if ([tableView tag] == 0) {
652+
653+
if (tableView == unstagedTable) {
651654
[self.index stageFiles:files];
652-
}
653-
else {
655+
} else {
654656
[self.index unstageFiles:files];
655657
}
656658
}

Classes/Controllers/PBGitHistoryController.h

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,34 @@ NS_ASSUME_NONNULL_BEGIN
3939
@property (readonly) BOOL singleCommitSelected;
4040
@property (readonly) BOOL singleNonHeadCommitSelected;
4141

42-
- (IBAction) setDetailedView:(id)sender;
43-
- (IBAction) setTreeView:(id)sender;
44-
- (IBAction) setBranchFilter:(id)sender;
45-
42+
- (BOOL)hasNonlinearPath;
43+
- (NSMenu *)tableColumnMenu;
4644
- (void)selectCommit:(GTOID *)commit;
47-
- (IBAction) refresh:(id)sender;
48-
- (IBAction) toggleQLPreviewPanel:(id)sender;
49-
- (IBAction) openSelectedFile:(id)sender;
50-
- (void) updateQuicklookForce: (BOOL) force;
45+
- (void)updateQuicklookForce: (BOOL) force;
46+
47+
- (void)setHistorySearch:(NSString *)searchString mode:(PBHistorySearchMode)mode;
5148

5249
// Context menu methods
5350
- (NSMenu *)contextMenuForTreeView;
5451
- (NSArray *)menuItemsForPaths:(NSArray *)paths;
5552
- (void)showCommitsFromTree:(id)sender;
5653

54+
- (IBAction)setDetailedView:(id)sender;
55+
- (IBAction)setTreeView:(id)sender;
56+
- (IBAction)setBranchFilter:(id)sender;
57+
58+
- (IBAction)refresh:(id)sender;
59+
- (IBAction)toggleQLPreviewPanel:(id)sender;
60+
- (IBAction)openSelectedFile:(id)sender;
61+
5762
// Find/Search methods
58-
- (void)setHistorySearch:(NSString *)searchString mode:(PBHistorySearchMode)mode;
5963
- (IBAction)selectNext:(id)sender;
6064
- (IBAction)selectPrevious:(id)sender;
6165

62-
63-
- (BOOL) hasNonlinearPath;
64-
65-
- (NSMenu *)tableColumnMenu;
66+
- (IBAction)copy:(id)sender;
67+
- (IBAction)copySHA:(id)sender;
68+
- (IBAction)copyShortName:(id)sender;
69+
- (IBAction)copyPatch:(id)sender;
6670

6771
@end
6872

Classes/Controllers/PBGitHistoryController.m

Lines changed: 54 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,48 @@ - (void)loadView {
8888

8989
self.selectedCommitDetailsIndex = [[NSUserDefaults standardUserDefaults] integerForKey:kHistorySelectedDetailIndexKey];
9090

91-
[commitController addObserver:self forKeyPath:@"selection" options:0 context:@"commitChange"];
92-
[commitController addObserver:self forKeyPath:@"arrangedObjects.@count" options:NSKeyValueObservingOptionInitial context:@"updateCommitCount"];
93-
[treeController addObserver:self forKeyPath:@"selection" options:0 context:@"treeChange"];
91+
[commitController addObserver:self keyPath:@"selection" options:0 block:^(MAKVONotification *notification) {
92+
PBGitHistoryController *observer = notification.observer;
93+
[observer updateKeys];
94+
}];
95+
96+
[commitController addObserver:self keyPath:@"arrangedObjects.@count" options:NSKeyValueObservingOptionInitial block:^(MAKVONotification *notification) {
97+
PBGitHistoryController *observer = notification.observer;
98+
[observer reselectCommitAfterUpdate];
99+
}];
100+
101+
[treeController addObserver:self keyPath:@"selection" options:0 block:^(MAKVONotification *notification) {
102+
PBGitHistoryController *observer = notification.observer;
103+
[observer updateQuicklookForce: NO];
104+
[observer saveFileBrowserSelection];
105+
}];
106+
107+
[repository.revisionList addObserver:self keyPath:@"isUpdating" options:0 block:^(MAKVONotification *notification) {
108+
PBGitHistoryController *observer = notification.observer;
109+
[observer reselectCommitAfterUpdate];
110+
}];
111+
112+
[repository addObserver:self keyPath:@"currentBranch" options:0 block:^(MAKVONotification *notification) {
113+
PBGitHistoryController *observer = notification.observer;
114+
// Reset the sorting
115+
if ([[observer.commitController sortDescriptors] count]) {
116+
[observer.commitController setSortDescriptors:[NSArray array]];
117+
[observer.commitController rearrangeObjects];
118+
}
119+
120+
[observer updateBranchFilterMatrix];
121+
}];
94122

95-
[repository.revisionList addObserver:self forKeyPath:@"isUpdating" options:0 context:@"revisionListUpdating"];
96-
[repository addObserver:self forKeyPath:@"currentBranch" options:0 context:@"branchChange"];
97-
[repository addObserver:self forKeyPath:@"refs" options:0 context:@"updateRefs"];
98-
[repository addObserver:self forKeyPath:@"currentBranchFilter" options:0 context:@"branchFilterChange"];
123+
[repository addObserver:self keyPath:@"refs" options:0 block:^(MAKVONotification *notification) {
124+
PBGitHistoryController *observer = notification.observer;
125+
[observer.commitController rearrangeObjects];
126+
}];
127+
128+
[repository addObserver:self keyPath:@"currentBranchFilter" options:0 block:^(MAKVONotification *notification) {
129+
PBGitHistoryController *observer = notification.observer;
130+
[PBGitDefaults setBranchFilter:observer.repository.currentBranchFilter];
131+
[observer updateBranchFilterMatrix];
132+
}];
99133

100134
forceSelectionUpdate = YES;
101135
NSSize cellSpacing = [commitList intercellSpacing];
@@ -131,9 +165,10 @@ - (void)loadView {
131165
// listen for updates
132166
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_repositoryUpdatedNotification:) name:PBGitRepositoryEventNotification object:repository];
133167

134-
__unsafe_unretained PBGitHistoryController *weakSelf = self;
168+
__weak typeof(self) weakSelf = self;
135169
commitList.findPanelActionBlock = ^(id sender) {
136-
[weakSelf.view.window makeFirstResponder:weakSelf->searchField];
170+
__strong typeof(weakSelf) strongSelf = weakSelf;
171+
[weakSelf.view.window makeFirstResponder:strongSelf->searchField];
137172
};
138173

139174
[super awakeFromNib];
@@ -147,6 +182,15 @@ - (void) _repositoryUpdatedNotification:(NSNotification *)notification {
147182
}
148183
}
149184

185+
- (void)reselectCommitAfterUpdate {
186+
[self updateStatus];
187+
188+
if ([self.repository.currentBranch isSimpleRef])
189+
[self selectCommit:[self.repository OIDForRef:self.repository.currentBranch.ref]];
190+
else
191+
[self selectCommit:self.firstCommit.OID];
192+
}
193+
150194
- (NSTableRowView *)tableView:(NSTableView *)tableView rowViewForRow:(NSInteger)row {
151195
NSTableRowView *view = [tableView rowViewAtRow:row makeIfNecessary:NO];
152196

@@ -309,56 +353,6 @@ - (void) saveFileBrowserSelection
309353
}
310354
}
311355

312-
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
313-
{
314-
NSString* strContext = (__bridge NSString*)context;
315-
if ([strContext isEqualToString: @"commitChange"]) {
316-
[self updateKeys];
317-
[self restoreFileBrowserSelection];
318-
return;
319-
}
320-
321-
if ([strContext isEqualToString: @"treeChange"]) {
322-
[self updateQuicklookForce: NO];
323-
[self saveFileBrowserSelection];
324-
return;
325-
}
326-
327-
if([strContext isEqualToString:@"branchChange"]) {
328-
// Reset the sorting
329-
if ([[commitController sortDescriptors] count]) {
330-
[commitController setSortDescriptors:[NSArray array]];
331-
[commitController rearrangeObjects];
332-
}
333-
334-
[self updateBranchFilterMatrix];
335-
return;
336-
}
337-
338-
if([strContext isEqualToString:@"updateRefs"]) {
339-
[commitController rearrangeObjects];
340-
return;
341-
}
342-
343-
if ([strContext isEqualToString:@"branchFilterChange"]) {
344-
[PBGitDefaults setBranchFilter:repository.currentBranchFilter];
345-
[self updateBranchFilterMatrix];
346-
return;
347-
}
348-
349-
if([strContext isEqualToString:@"updateCommitCount"] || [(__bridge NSString *)context isEqualToString:@"revisionListUpdating"]) {
350-
[self updateStatus];
351-
352-
if ([repository.currentBranch isSimpleRef])
353-
[self selectCommit:[repository OIDForRef:repository.currentBranch.ref]];
354-
else
355-
[self selectCommit:self.firstCommit.OID];
356-
return;
357-
}
358-
359-
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
360-
}
361-
362356
- (IBAction) openSelectedFile:(id)sender
363357
{
364358
NSArray* selectedFiles = [treeController selectedObjects];
@@ -563,17 +557,7 @@ - (BOOL) hasNonlinearPath
563557

564558
- (void)closeView
565559
{
566-
if (commitController) {
567-
[[NSNotificationCenter defaultCenter] removeObserver:self];
568-
[commitController removeObserver:self forKeyPath:@"selection"];
569-
[commitController removeObserver:self forKeyPath:@"arrangedObjects.@count"];
570-
[treeController removeObserver:self forKeyPath:@"selection"];
571-
572-
[repository.revisionList removeObserver:self forKeyPath:@"isUpdating"];
573-
[repository removeObserver:self forKeyPath:@"currentBranch"];
574-
[repository removeObserver:self forKeyPath:@"refs"];
575-
[repository removeObserver:self forKeyPath:@"currentBranchFilter"];
576-
}
560+
[[NSNotificationCenter defaultCenter] removeObserver:self];
577561

578562
[webHistoryController closeView];
579563
[fileView closeView];

Classes/Controllers/PBGitSidebarController.h

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,23 @@
1414
@class PBGitHistoryController;
1515
@class PBGitCommitController;
1616

17-
@interface PBGitSidebarController : PBViewController<NSOutlineViewDelegate> {
18-
__weak IBOutlet NSWindow *window;
19-
__weak IBOutlet NSOutlineView *sourceView;
20-
__weak IBOutlet NSView *sourceListControlsView;
21-
__weak IBOutlet NSPopUpButton *actionButton;
22-
__weak IBOutlet NSSegmentedControl *remoteControls;
17+
NS_ASSUME_NONNULL_BEGIN
2318

24-
NSMutableArray *items;
19+
@interface PBGitSidebarController : PBViewController
2520

26-
/* Specific things */
27-
PBSourceViewItem *stage;
21+
- (void)selectStage;
22+
- (void)selectCurrentBranch;
2823

29-
PBSourceViewItem *branches, *remotes, *tags, *others, *submodules, *stashes;
30-
}
24+
- (NSMenu *)menuForRow:(NSInteger)row;
25+
- (void)menuNeedsUpdate:(NSMenu *)menu;
3126

32-
- (void) selectStage;
33-
- (void) selectCurrentBranch;
27+
- (IBAction)fetchPullPushAction:(id)sender;
3428

35-
- (NSMenu *) menuForRow:(NSInteger)row;
36-
- (void) menuNeedsUpdate:(NSMenu *)menu;
37-
38-
- (IBAction) fetchPullPushAction:(id)sender;
39-
40-
@property(readonly) NSMutableArray *items;
41-
@property(readonly) PBSourceViewItem *remotes;
42-
@property(readonly) NSOutlineView *sourceView;
43-
@property(readonly) NSView *sourceListControlsView;
29+
@property (readonly) NSMutableArray *items;
30+
@property (readonly) PBSourceViewItem *remotes;
31+
@property (readonly) NSOutlineView *sourceView;
32+
@property (readonly) NSView *sourceListControlsView;
4433

4534
@end
35+
36+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)