@@ -68,19 +68,33 @@ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem
68
68
[menuItem setState: (contentController != sidebarController.commitViewController) ? YES : NO ];
69
69
return ![repository isBareRepository ];
70
70
} else if (menuItem.action == @selector (fetchRemote: )) {
71
- NSOutlineView *sourceView = sidebarController.sourceView ;
72
- PBSourceViewItem *item = [sourceView itemAtRow: sourceView.selectedRow];
73
- if (item.ref .isRemote ) {
74
- menuItem.title = [NSString stringWithFormat: NSLocalizedString(@" Fetch “%@ ”" , @" Fetch ”Remote Name“" ), item.ref.remoteName];
75
- return YES ;
76
- }
77
- menuItem.title = NSLocalizedString(@" Fetch" , @" Fetch (without Remote Name for inactive menu item)" );
78
- return NO ;
71
+ return [self validateMenuItem: menuItem remoteTitle: @" Fetch “%@ ”" plainTitle: @" Fetch" ];
72
+ } else if (menuItem.action == @selector (pullRemote: )) {
73
+ return [self validateMenuItem: menuItem remoteTitle: @" Pull From “%@ ”" plainTitle: @" Pull" ];
79
74
}
80
75
81
76
return YES ;
82
77
}
83
78
79
+ - (BOOL ) validateMenuItem : (NSMenuItem *)menuItem remoteTitle : (NSString *)localisationKeyWithRemote plainTitle : (NSString *)localizationKeyWithoutRemote
80
+ {
81
+ PBSourceViewItem *item = [self selectedItem ];
82
+ PBGitRef *ref = item.ref ;
83
+
84
+ if (!ref && (item.parent == sidebarController.remotes )) {
85
+ ref = [PBGitRef refFromString: [kGitXRemoteRefPrefix stringByAppendingString: item.title]];
86
+ }
87
+
88
+ if (ref.isRemote ) {
89
+ menuItem.title = [NSString stringWithFormat: NSLocalizedString(localisationKeyWithRemote, @" " ), ref.remoteName];
90
+ return YES ;
91
+ }
92
+
93
+ menuItem.title = NSLocalizedString(localizationKeyWithoutRemote, @" " );
94
+ return NO ;
95
+ }
96
+
97
+
84
98
- (void ) awakeFromNib
85
99
{
86
100
[[self window ] setDelegate: self ];
@@ -261,15 +275,30 @@ - (IBAction) showAddRemoteSheet:(id)sender
261
275
262
276
263
277
- (IBAction ) fetchRemote : (id )sender {
264
- NSOutlineView *sourceView = sidebarController.sourceView ;
265
- PBSourceViewItem *item = [sourceView itemAtRow: sourceView.selectedRow];
266
- [repository beginFetchFromRemoteForRef: item.ref];
278
+ PBGitRef *ref = [self selectedItem ].ref ;
279
+ [repository beginFetchFromRemoteForRef: ref];
267
280
}
268
281
269
282
- (IBAction ) fetchAllRemotes : (id )sender {
270
283
[repository beginFetchFromRemoteForRef: nil ];
271
284
}
272
285
286
+ - (IBAction ) pullRemote : (id )sender {
287
+ PBGitRef *ref = [self selectedItem ].revSpecifier .ref ;
288
+ PBGitRef *remoteRef = [repository remoteRefForBranch: ref error: NULL ];
289
+ [repository beginPullFromRemote: remoteRef forRef: ref];
290
+ }
291
+
292
+ - (IBAction ) pullDefaultRemote : (id )sender {
293
+ PBGitRef *ref = [self selectedItem ].revSpecifier .ref ;
294
+ [repository beginPullFromRemote: nil forRef: ref];
295
+ }
296
+
297
+ - (PBSourceViewItem *) selectedItem {
298
+ NSOutlineView *sourceView = sidebarController.sourceView ;
299
+ return [sourceView itemAtRow: sourceView.selectedRow];
300
+ }
301
+
273
302
- (IBAction ) stashSave : (id ) sender
274
303
{
275
304
[repository stashSaveWithKeepIndex: NO ];
0 commit comments