From dda41e4440e549a83d9a9dfcd3a0ded093c8db66 Mon Sep 17 00:00:00 2001 From: Rowan James Date: Tue, 20 Aug 2013 12:50:45 +1000 Subject: [PATCH] Disable 'delete' ref menu item for remote branches It didn't actually perform the remote delete, just dropped the local copy of the ref. --- Classes/Views/PBRefMenuItem.m | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Classes/Views/PBRefMenuItem.m b/Classes/Views/PBRefMenuItem.m index fed45abe4..f7a944554 100644 --- a/Classes/Views/PBRefMenuItem.m +++ b/Classes/Views/PBRefMenuItem.m @@ -47,8 +47,9 @@ + (NSArray *) defaultMenuItemsForRef:(PBGitRef *)ref inRepository:(PBGitReposito BOOL isDetachedHead = (isHead && [headRefName isEqualToString:@"HEAD"]); NSString *remoteName = [ref remoteName]; - if (!remoteName && [ref isBranch]) + if (!remoteName && [ref isBranch]) { remoteName = [[repo remoteRefForBranch:ref error:NULL] remoteName]; + } BOOL hasRemote = (remoteName ? YES : NO); BOOL isRemote = ([ref isRemote] && ![ref isRemoteBranch]); @@ -131,8 +132,12 @@ + (NSArray *) defaultMenuItemsForRef:(PBGitRef *)ref inRepository:(PBGitReposito // delete ref [items addObject:[PBRefMenuItem separatorItem]]; - NSString *deleteTitle = [NSString stringWithFormat:@"Delete %@…", targetRefName]; - [items addObject:[PBRefMenuItem itemWithTitle:deleteTitle action:@selector(showDeleteRefSheet:) enabled:!isDetachedHead]]; + { + NSString *deleteTitle = [NSString stringWithFormat:@"Delete %@…", targetRefName]; + BOOL deleteEnabled = !(isDetachedHead || [ref isRemote]); + PBRefMenuItem *deleteItem = [PBRefMenuItem itemWithTitle:deleteTitle action:@selector(showDeleteRefSheet:) enabled:deleteEnabled]; + [items addObject:deleteItem]; + } for (PBRefMenuItem *item in items) { [item setTarget:target];