Skip to content

Commit 85318a7

Browse files
committed
Rewire fetch and fix a few issues
1 parent 25621b3 commit 85318a7

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

Classes/Controllers/PBGitHistoryController.m

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -645,15 +645,6 @@ - (NSArray *)menuItemsForPaths:(NSArray *)paths
645645
return [self.windowController performSelector:@selector(refishForSender:refishTypes:) withObject:sender withObject:types];
646646
}
647647

648-
- (IBAction)fetchRemote:(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 performFetchForRef:refish];
655-
}
656-
657648
- (IBAction)pullRemote:(id)sender
658649
{
659650
id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXBranchType]];

Classes/Controllers/PBGitWindowController.m

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ - (BOOL) validateMenuItem:(NSMenuItem *)menuItem remoteTitle:(NSString *)localis
9292
if (!ref && (item.parent == sidebarController.remotes)) {
9393
ref = [PBGitRef refFromString:[kGitXRemoteRefPrefix stringByAppendingString:item.title]];
9494
}
95-
96-
if (ref.isRemote) {
97-
menuItem.title = [NSString stringWithFormat:NSLocalizedString(localisationKeyWithRemote, @""), ref.remoteName];
95+
96+
PBGitRef *remoteRef = [self.repository remoteRefForBranch:ref error:NULL];
97+
if (ref.isRemote || remoteRef) {
98+
menuItem.title = [NSString stringWithFormat:NSLocalizedString(localisationKeyWithRemote, @""), (!remoteRef ? ref.remoteName : remoteRef.remoteName)];
9899
menuItem.representedObject = ref;
99100
return YES;
100101
}
@@ -269,11 +270,17 @@ - (void)revealURLsInFinder:(NSArray <NSURL *> *)fileURLs
269270

270271
- (void)performFetchForRef:(PBGitRef *)ref
271272
{
272-
NSString *remoteName = (ref ? ref.remoteName : @"all remotes");
273-
NSString *description = [NSString stringWithFormat:@"Fetching tracking branches for %@", remoteName];
273+
NSString *desc = nil;
274+
if (ref == nil) {
275+
desc = [NSString stringWithFormat:@"Fetching all remotes"];
276+
} else if (ref.isRemote || ref.isRemoteBranch) {
277+
desc = [NSString stringWithFormat:@"Fetching branches from remote %@", ref.remoteName];
278+
} else {
279+
desc = [NSString stringWithFormat:@"Fetching tracking branch for %@", ref.shortName];
280+
}
274281

275282
PBRemoteProgressSheet *progressSheet = [PBRemoteProgressSheet progressSheetWithTitle:@"Fetching remote…"
276-
description:description
283+
description:desc
277284
windowController:self];
278285

279286
[progressSheet beginProgressSheetForBlock:^{
@@ -458,10 +465,13 @@ - (IBAction)addRemote:(id)sender
458465
}];
459466
}
460467

461-
- (IBAction) fetchRemote:(id)sender {
462-
/* FIXME: this is wrong, you can right-click in the sidebar but try to fetch the *selected* ref */
463-
PBGitRef *ref = [self selectedItem].ref;
464-
[self performFetchForRef:ref];
468+
- (IBAction)fetchRemote:(id)sender
469+
{
470+
id <PBGitRefish> refish = [self refishForSender:sender refishTypes:@[kGitXBranchType, kGitXRemoteType]];
471+
if (!refish || ![refish isKindOfClass:[PBGitRef class]])
472+
return;
473+
474+
[self performFetchForRef:refish];
465475
}
466476

467477
- (IBAction) fetchAllRemotes:(id)sender {

0 commit comments

Comments
 (0)