mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Merge pull request #61 from Uncommon/helptags
Help tags for remotes and tags
This commit is contained in:
@@ -128,6 +128,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;
|
||||
|
||||
@@ -292,6 +292,41 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
|
||||
[refs setObject:[NSMutableArray arrayWithObject:ref] forKey:sha];
|
||||
}
|
||||
|
||||
// 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 isTag]) {
|
||||
arguments = [NSArray arrayWithObjects:@"tag", @"-ln", name, nil];
|
||||
output = [self outputForArguments:arguments];
|
||||
if (![output hasPrefix:name])
|
||||
return nil;
|
||||
return [[output substringFromIndex:[name length]] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void) reloadRefs
|
||||
{
|
||||
_headRef = nil;
|
||||
@@ -321,6 +356,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
|
||||
PBGitRef *newRef = [PBGitRef refFromString:[components objectAtIndex:0]];
|
||||
PBGitRevSpecifier *revSpec = [[PBGitRevSpecifier alloc] initWithRef:newRef];
|
||||
|
||||
[revSpec setHelpText:[self helpTextForRef:newRef]];
|
||||
[self addBranch:revSpec];
|
||||
[self addRef:newRef fromParameters:components];
|
||||
[oldBranches removeObject:revSpec];
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
@interface PBGitRevSpecifier : NSObject <NSCopying> {
|
||||
NSString *description;
|
||||
NSString *helpText;
|
||||
NSArray *parameters;
|
||||
NSURL *workingDirectory;
|
||||
BOOL isSimpleRef;
|
||||
@@ -36,6 +37,7 @@
|
||||
+ (PBGitRevSpecifier *)localBranchesRevSpec;
|
||||
|
||||
@property(retain) NSString *description;
|
||||
@property(retain) NSString *helpText;
|
||||
@property(readonly) NSArray *parameters;
|
||||
@property(retain) NSURL *workingDirectory;
|
||||
@property(readonly) BOOL isSimpleRef;
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
|
||||
@implementation PBGitRevSpecifier
|
||||
|
||||
@synthesize parameters, description, workingDirectory;
|
||||
@synthesize parameters, description, helpText, workingDirectory;
|
||||
@synthesize isSimpleRef;
|
||||
@synthesize behind,ahead;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -342,6 +342,11 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged";
|
||||
[cell setImage:[item icon]];
|
||||
}
|
||||
|
||||
- (NSString *)outlineView:(NSOutlineView *)outlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation
|
||||
{
|
||||
return [item helpText];
|
||||
}
|
||||
|
||||
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item
|
||||
{
|
||||
return ![item isGroupItem];
|
||||
@@ -360,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]];
|
||||
@@ -379,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