-
Notifications
You must be signed in to change notification settings - Fork 601
/
PBRefMenuItem.m
46 lines (38 loc) · 1.21 KB
/
PBRefMenuItem.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// PBRefMenuItem.m
// GitX
//
// Created by Pieter de Bie on 01-11-08.
// Copyright 2008 Pieter de Bie. All rights reserved.
//
#import "PBRefMenuItem.h"
@implementation PBRefMenuItem
@synthesize ref, commit;
+ (NSArray *)defaultMenuItemsForRef:(PBGitRef *)ref commit:(PBGitCommit *)commit target:(id)target
{
NSMutableArray *array = [NSMutableArray array];
NSString *type = [ref type];
if ([type isEqualToString:@"remote"])
type = @"remote branch";
else if ([type isEqualToString:@"head"])
type = @"branch";
[array addObject:[[PBRefMenuItem alloc] initWithTitle:[@"Delete " stringByAppendingString:type]
action:@selector(removeRef:)
keyEquivalent: @""]];
if ([type isEqualToString:@"branch"])
[array addObject:[[PBRefMenuItem alloc] initWithTitle:@"Checkout branch"
action:@selector(checkoutRef:)
keyEquivalent: @""]];
if ([type isEqualToString:@"tag"])
[array addObject:[[PBRefMenuItem alloc] initWithTitle:@"View tag info"
action:@selector(tagInfo:)
keyEquivalent: @""]];
for (PBRefMenuItem *item in array)
{
[item setTarget: target];
[item setRef: ref];
[item setCommit:commit];
}
return array;
}
@end