mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
help tags for remotes now work
This commit is contained in:
@@ -127,6 +127,7 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) {
|
||||
- (BOOL) hasRemotes;
|
||||
- (PBGitRef *) remoteRefForBranch:(PBGitRef *)branch error:(NSError **)error;
|
||||
- (NSString *) infoForRemote:(NSString *)remoteName;
|
||||
- (NSArray*) URLsForRemote:(NSString*)remoteName;
|
||||
|
||||
- (void) readCurrentBranch;
|
||||
- (PBGitRevSpecifier*) addBranch: (PBGitRevSpecifier*) rev;
|
||||
|
||||
+20
-11
@@ -278,23 +278,32 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
|
||||
[refs setObject:[NSMutableArray arrayWithObject:ref] forKey:sha];
|
||||
}
|
||||
|
||||
// Extracts the text that should be shown in a help tag
|
||||
// Returns the remote's fetch and pull URLs as an array of two strings.
|
||||
- (NSArray*) URLsForRemote:(NSString*)remoteName
|
||||
{
|
||||
NSArray *arguments = [NSArray arrayWithObjects:@"remote", @"show", @"-n", remoteName, nil];
|
||||
NSString *output = [self outputForArguments:arguments];
|
||||
|
||||
NSArray *remoteLines = [output componentsSeparatedByString:@"\n"];
|
||||
NSString *fetchURL = [remoteLines objectAtIndex:1];
|
||||
NSString *pushURL = [remoteLines objectAtIndex:2];
|
||||
|
||||
if ([fetchURL hasPrefix:@" Fetch URL: "] && [pushURL hasPrefix:@" Push URL: "])
|
||||
return [NSArray arrayWithObjects:
|
||||
[fetchURL substringFromIndex:13],
|
||||
[pushURL substringFromIndex:13],
|
||||
nil];
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Extracts the text that should be shown in a help tag.
|
||||
- (NSString*) helpTextForRef:(PBGitRef*)ref
|
||||
{
|
||||
NSString *output = nil;
|
||||
NSString *name = [ref shortName];
|
||||
NSArray *arguments = nil;
|
||||
|
||||
if ([ref isRemote]) {
|
||||
arguments = [NSArray arrayWithObjects:@"remote", @"show", @"-n", name, nil];
|
||||
output = [self outputForArguments:arguments];
|
||||
|
||||
NSArray *remoteLines = [output componentsSeparatedByString:@"\n"];
|
||||
|
||||
// Second and third lines have Fetch and Push URLs
|
||||
return [[remoteLines subarrayWithRange:NSMakeRange(1,1)] componentsJoinedByString:@"\n"];
|
||||
}
|
||||
else if ([ref isTag]) {
|
||||
if ([ref isTag]) {
|
||||
arguments = [NSArray arrayWithObjects:@"tag", @"-ln", name, nil];
|
||||
output = [self outputForArguments:arguments];
|
||||
if (![output hasPrefix:name])
|
||||
|
||||
@@ -12,9 +12,11 @@
|
||||
|
||||
@interface PBGitSVRemoteItem : PBSourceViewItem {
|
||||
BOOL alert;
|
||||
NSString *helpText;
|
||||
}
|
||||
|
||||
@property (assign) BOOL alert;
|
||||
@property (retain) NSString *helpText;
|
||||
|
||||
+ (id)remoteItemWithTitle:(NSString *)title;
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
@implementation PBGitSVRemoteItem
|
||||
|
||||
@synthesize alert;
|
||||
@synthesize helpText;
|
||||
|
||||
+ (id)remoteItemWithTitle:(NSString *)title
|
||||
{
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
IBOutlet NSPopUpButton *actionButton;
|
||||
IBOutlet NSSegmentedControl *remoteControls;
|
||||
|
||||
IBOutlet NSButton* svnFetchButton;
|
||||
IBOutlet NSButton* svnRebaseButton;
|
||||
IBOutlet NSButton* svnDcommitButton;
|
||||
IBOutlet NSButton* svnFetchButton;
|
||||
IBOutlet NSButton* svnRebaseButton;
|
||||
IBOutlet NSButton* svnDcommitButton;
|
||||
|
||||
NSMutableArray *items;
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged";
|
||||
|
||||
- (NSString *)outlineView:(NSOutlineView *)outlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation
|
||||
{
|
||||
return [[item revSpecifier] helpText];
|
||||
return [item helpText];
|
||||
}
|
||||
|
||||
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item
|
||||
@@ -365,6 +365,17 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged";
|
||||
return ![item isUncollapsible];
|
||||
}
|
||||
|
||||
- (NSString*) helpTextForRemoteURLs:(NSArray*)urls
|
||||
{
|
||||
NSString *fetchURL = [urls objectAtIndex:0];
|
||||
NSString *pushURL = [urls objectAtIndex:1];
|
||||
|
||||
if ([fetchURL isEqual:pushURL])
|
||||
return fetchURL;
|
||||
else // Down triangle for fetch, up triangle for push
|
||||
return [NSString stringWithFormat:@"\u25bc %@\n\u25b2", fetchURL, pushURL];
|
||||
}
|
||||
|
||||
- (void)populateList
|
||||
{
|
||||
PBSourceViewItem *project = [PBSourceViewItem groupItemWithTitle:[repository projectName]];
|
||||
@@ -384,6 +395,8 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged";
|
||||
|
||||
for (PBGitRevSpecifier *rev in repository.branches)
|
||||
[self addRevSpec:rev];
|
||||
for (PBGitSVRemoteItem *remote in remotes.children)
|
||||
[remote setHelpText:[self helpTextForRemoteURLs:[[self repository] URLsForRemote:[remote title]]]];
|
||||
|
||||
[items addObject:project];
|
||||
[items addObject:branches];
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
+ (id)itemWithTitle:(NSString *)title;
|
||||
|
||||
- (NSString *)badge;
|
||||
- (NSString *)helpText;
|
||||
|
||||
- (void)addChild:(PBSourceViewItem *)child;
|
||||
- (void)removeChild:(PBSourceViewItem *)child;
|
||||
|
||||
@@ -128,6 +128,11 @@
|
||||
return [[revSpecifier description] lastPathComponent];
|
||||
}
|
||||
|
||||
- (NSString *) helpText
|
||||
{
|
||||
return [revSpecifier helpText];
|
||||
}
|
||||
|
||||
- (NSString *) stringValue
|
||||
{
|
||||
return self.title;
|
||||
|
||||
Reference in New Issue
Block a user