Skip to content

Commit dda41e4

Browse files
committed
Disable 'delete' ref menu item for remote branches
It didn't actually perform the remote delete, just dropped the local copy of the ref.
1 parent a226ffb commit dda41e4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Classes/Views/PBRefMenuItem.m

+8-3
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ + (NSArray *) defaultMenuItemsForRef:(PBGitRef *)ref inRepository:(PBGitReposito
4747
BOOL isDetachedHead = (isHead && [headRefName isEqualToString:@"HEAD"]);
4848

4949
NSString *remoteName = [ref remoteName];
50-
if (!remoteName && [ref isBranch])
50+
if (!remoteName && [ref isBranch]) {
5151
remoteName = [[repo remoteRefForBranch:ref error:NULL] remoteName];
52+
}
5253
BOOL hasRemote = (remoteName ? YES : NO);
5354
BOOL isRemote = ([ref isRemote] && ![ref isRemoteBranch]);
5455

@@ -131,8 +132,12 @@ + (NSArray *) defaultMenuItemsForRef:(PBGitRef *)ref inRepository:(PBGitReposito
131132

132133
// delete ref
133134
[items addObject:[PBRefMenuItem separatorItem]];
134-
NSString *deleteTitle = [NSString stringWithFormat:@"Delete %@", targetRefName];
135-
[items addObject:[PBRefMenuItem itemWithTitle:deleteTitle action:@selector(showDeleteRefSheet:) enabled:!isDetachedHead]];
135+
{
136+
NSString *deleteTitle = [NSString stringWithFormat:@"Delete %@", targetRefName];
137+
BOOL deleteEnabled = !(isDetachedHead || [ref isRemote]);
138+
PBRefMenuItem *deleteItem = [PBRefMenuItem itemWithTitle:deleteTitle action:@selector(showDeleteRefSheet:) enabled:deleteEnabled];
139+
[items addObject:deleteItem];
140+
}
136141

137142
for (PBRefMenuItem *item in items) {
138143
[item setTarget:target];

0 commit comments

Comments
 (0)