18
18
NSString * const kGitXBranchRefPrefix = @" refs/heads/" ;
19
19
NSString * const kGitXRemoteRefPrefix = @" refs/remotes/" ;
20
20
21
+ @interface PBGitRef ()
22
+ @property (nonatomic , strong ) NSString * ref;
23
+ @end
21
24
22
25
@implementation PBGitRef
23
26
24
- @synthesize ref;
25
-
26
27
- (NSString *) tagName
27
28
{
28
29
if (![self isTag ])
@@ -44,7 +45,7 @@ - (NSString *) remoteName
44
45
if (![self isRemote ])
45
46
return nil ;
46
47
47
- return (NSString *)[[ref componentsSeparatedByString: @" /" ] objectAtIndex: 2 ];
48
+ return (NSString *)[[self . ref componentsSeparatedByString: @" /" ] objectAtIndex: 2 ];
48
49
}
49
50
50
51
- (NSString *) remoteBranchName
@@ -68,30 +69,30 @@ - (NSString *) type
68
69
69
70
- (BOOL ) isBranch
70
71
{
71
- return [ref hasPrefix: kGitXBranchRefPrefix ];
72
+ return [self . ref hasPrefix: kGitXBranchRefPrefix ];
72
73
}
73
74
74
75
- (BOOL ) isTag
75
76
{
76
- return [ref hasPrefix: kGitXTagRefPrefix ];
77
+ return [self . ref hasPrefix: kGitXTagRefPrefix ];
77
78
}
78
79
79
80
- (BOOL ) isRemote
80
81
{
81
- return [ref hasPrefix: kGitXRemoteRefPrefix ];
82
+ return [self . ref hasPrefix: kGitXRemoteRefPrefix ];
82
83
}
83
84
84
85
- (BOOL ) isRemoteBranch
85
86
{
86
87
if (![self isRemote ])
87
88
return NO ;
88
89
89
- return ([[ref componentsSeparatedByString: @" /" ] count ] > 3 );
90
+ return ([[self . ref componentsSeparatedByString: @" /" ] count ] > 3 );
90
91
}
91
92
92
93
- (BOOL ) isEqualToRef : (PBGitRef *)otherRef
93
94
{
94
- return [ref isEqualToString: [otherRef ref ]];
95
+ return [self . ref isEqualToString: [otherRef ref ]];
95
96
}
96
97
97
98
- (PBGitRef *) remoteRef
@@ -109,7 +110,11 @@ + (PBGitRef*) refFromString: (NSString*) s
109
110
110
111
- (PBGitRef*) initWithString : (NSString *) s
111
112
{
112
- ref = s;
113
+ self = [super init ];
114
+ if (!self) {
115
+ return nil ;
116
+ }
117
+ self.ref = s;
113
118
return self;
114
119
}
115
120
@@ -127,14 +132,16 @@ + (BOOL)isKeyExcludedFromWebScript:(const char *)name {
127
132
128
133
- (NSString *) refishName
129
134
{
130
- return ref;
135
+ return self. ref ;
131
136
}
132
137
133
138
- (NSString *) shortName
134
139
{
135
- if ([self type ])
136
- return [ref substringFromIndex: [[self type ] length ] + 7 ];
137
- return ref;
140
+ if ([self type ]) {
141
+ return [self .ref substringFromIndex: [[self type ] length ] + 7 ];
142
+ }
143
+
144
+ return self.ref ;
138
145
}
139
146
140
147
- (NSString *) refishType
0 commit comments