mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Disable the push menu item for branches which don't have a remote.
This commit is contained in:
committed by
André Berg
parent
cdc4f5208b
commit
4b74a3f92a
+2
-1
@@ -291,8 +291,9 @@
|
||||
if (!ref)
|
||||
return [self menu];
|
||||
|
||||
NSArray *items = [contextMenuDelegate menuItemsForRef:ref commit:[self objectValue]];
|
||||
NSMenu *menu = [[NSMenu alloc] init];
|
||||
[menu setAutoenablesItems:NO];
|
||||
NSArray *items = [contextMenuDelegate menuItemsForRef:ref commit:[self objectValue]];
|
||||
for (NSMenuItem *item in items)
|
||||
[menu addItem:item];
|
||||
return menu;
|
||||
|
||||
+15
-9
@@ -21,19 +21,25 @@
|
||||
else if ([type isEqualToString:@"head"])
|
||||
type = @"branch";
|
||||
|
||||
[array addObject:[[PBRefMenuItem alloc] initWithTitle:[@"Delete " stringByAppendingString:type]
|
||||
action:@selector(removeRef:)
|
||||
keyEquivalent: @""]];
|
||||
NSString *remote = [[[commit repository] config] valueForKeyPath:[NSString stringWithFormat:@"branch.%@.remote", [ref shortName]]];
|
||||
bool has_remote = remote != NULL;
|
||||
|
||||
if ([type isEqualToString:@"branch"]) {
|
||||
PBRefMenuItem *push = [[PBRefMenuItem alloc] initWithTitle:@"Push branch"
|
||||
action:@selector(pushRef:)
|
||||
keyEquivalent: @""];
|
||||
if(!has_remote) [push setEnabled:NO];
|
||||
[array addObject:push];
|
||||
}
|
||||
|
||||
if ([type isEqualToString:@"branch"])
|
||||
[array addObject:[[PBRefMenuItem alloc] initWithTitle:@"Checkout branch"
|
||||
action:@selector(checkoutRef:)
|
||||
keyEquivalent: @""]];
|
||||
|
||||
if ([type isEqualToString:@"branch"])
|
||||
[array addObject:[[PBRefMenuItem alloc] initWithTitle:@"Push branch"
|
||||
action:@selector(pushRef:)
|
||||
keyEquivalent: @""]];
|
||||
|
||||
|
||||
[array addObject:[[PBRefMenuItem alloc] initWithTitle:[@"Delete " stringByAppendingString:type]
|
||||
action:@selector(removeRef:)
|
||||
keyEquivalent: @""]];
|
||||
if ([type isEqualToString:@"tag"])
|
||||
[array addObject:[[PBRefMenuItem alloc] initWithTitle:@"View tag info"
|
||||
action:@selector(tagInfo:)
|
||||
|
||||
Reference in New Issue
Block a user