Skip to content

Commit

Permalink
Disable 'delete' ref menu item for remote branches
Browse files Browse the repository at this point in the history
It didn't actually perform the remote delete, just dropped the local copy of the ref.
  • Loading branch information
rowanj committed Aug 20, 2013
1 parent a226ffb commit dda41e4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Classes/Views/PBRefMenuItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit dda41e4

Please sign in to comment.