Skip to content

Commit 43e3d46

Browse files
David CatmullDavid Catmull
authored andcommitted
helpTextForRef
1 parent b0090ce commit 43e3d46

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

PBGitRepository.m

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,32 @@ - (void) addRef: (PBGitRef *) ref fromParameters: (NSArray *) components
278278
[refs setObject:[NSMutableArray arrayWithObject:ref] forKey:sha];
279279
}
280280

281+
// Extracts the text that should be shown in a help tag
282+
- (NSString*) helpTextForRef:(PBGitRef*)ref
283+
{
284+
NSString *output = nil;
285+
NSString *name = [ref shortName];
286+
NSArray *arguments = nil;
287+
288+
if ([ref isRemote]) {
289+
arguments = [NSArray arrayWithObjects:@"remote", @"show", @"-n", name, nil];
290+
output = [self outputForArguments:arguments];
291+
292+
NSArray *remoteLines = [output componentsSeparatedByString:@"\n"];
293+
294+
// Second and third lines have Fetch and Push URLs
295+
return [[remoteLines subarrayWithRange:NSMakeRange(1,1)] componentsJoinedByString:@"\n"];
296+
}
297+
else if ([ref isTag]) {
298+
arguments = [NSArray arrayWithObjects:@"tag", @"-ln", name, nil];
299+
output = [self outputForArguments:arguments];
300+
if (![output hasPrefix:name])
301+
return nil;
302+
return [[output substringFromIndex:[name length]] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
303+
}
304+
return nil;
305+
}
306+
281307
- (void) reloadRefs
282308
{
283309
_headRef = nil;

0 commit comments

Comments
 (0)