mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
c36726b985
- In PBGitSidebarView.xib
- change indentation to 12
- change font size to 11
- disable the editable behavior
- disable autoresizing
- disable user resizing (column should resize with view)
- remove the window
- remove the shared user defaults controller (not being used)
- add a project item with the project's name
- a "Stage" item to go to what has been called the commit view
- new icons for branches, remote branches and tags (created by Nathan Kinsinger)
- remove the old tiff icons, PBSourceViewRemote.h/m and PBSourceViewAction.h/m from the xcode project
- uses system icon for folder
- uses Network icon for remotes
- capitalize group names
- rename the Custom group to Other (you can't really customize items in the traditional sense)
- create a class for each item type that takes care of it's image (instead of trying to guess the image from it or it's parent's name)
- remove the branch menu toolbar item from the history view, it's redundant now
154 lines
3.5 KiB
Objective-C
154 lines
3.5 KiB
Objective-C
//
|
|
// PBGitRevSpecifier.m
|
|
// GitX
|
|
//
|
|
// Created by Pieter de Bie on 12-09-08.
|
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
|
//
|
|
|
|
#import "PBGitRevSpecifier.h"
|
|
|
|
|
|
@implementation PBGitRevSpecifier
|
|
|
|
@synthesize parameters, description, workingDirectory;
|
|
|
|
- (id) initWithParameters:(NSArray*) params
|
|
{
|
|
parameters = params;
|
|
description = nil;
|
|
return self;
|
|
}
|
|
|
|
- (id) initWithRef: (PBGitRef*) ref
|
|
{
|
|
parameters = [NSArray arrayWithObject: ref.ref];
|
|
description = ref.shortName;
|
|
return self;
|
|
}
|
|
|
|
- (id) initWithCoder:(NSCoder *)coder
|
|
{
|
|
parameters = [coder decodeObjectForKey:@"Parameters"];
|
|
description = [coder decodeObjectForKey:@"Description"];
|
|
return self;
|
|
}
|
|
|
|
+ (PBGitRevSpecifier *)allBranchesRevSpec
|
|
{
|
|
id revspec = [[PBGitRevSpecifier alloc] initWithParameters:[NSArray arrayWithObject:@"--all"]];
|
|
[revspec setDescription:@"All branches"];
|
|
return revspec;
|
|
}
|
|
|
|
+ (PBGitRevSpecifier *)localBranchesRevSpec
|
|
{
|
|
id revspec = [[PBGitRevSpecifier alloc] initWithParameters:[NSArray arrayWithObject:@"--branches"]];
|
|
[revspec setDescription:@"Local branches"];
|
|
return revspec;
|
|
}
|
|
|
|
- (BOOL) isSimpleRef
|
|
{
|
|
if ([parameters count] > 1)
|
|
return NO;
|
|
|
|
NSString *param = [parameters objectAtIndex:0];
|
|
if ([param hasPrefix:@"-"] ||
|
|
[param rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"^@{}~:"]].location != NSNotFound ||
|
|
[param rangeOfString:@".."].location != NSNotFound)
|
|
return NO;
|
|
|
|
return YES;
|
|
}
|
|
|
|
- (NSString*) simpleRef
|
|
{
|
|
if (![self isSimpleRef])
|
|
return nil;
|
|
return [parameters objectAtIndex:0];
|
|
}
|
|
|
|
- (PBGitRef *) ref
|
|
{
|
|
if (![self isSimpleRef])
|
|
return nil;
|
|
|
|
return [PBGitRef refFromString:[self simpleRef]];
|
|
}
|
|
|
|
- (NSString*) description
|
|
{
|
|
if (description)
|
|
return description;
|
|
|
|
return [parameters componentsJoinedByString:@" "];
|
|
}
|
|
|
|
- (NSString *) title
|
|
{
|
|
NSString *title = nil;
|
|
|
|
if ([self.description isEqualToString:@"HEAD"])
|
|
title = @"detached HEAD";
|
|
else if ([self isSimpleRef])
|
|
title = [[self ref] shortName];
|
|
else if ([self.description hasPrefix:@"-S"])
|
|
title = [self.description substringFromIndex:[@"-S" length]];
|
|
else if ([self.description hasPrefix:@"HEAD -- "])
|
|
title = [self.description substringFromIndex:[@"HEAD -- " length]];
|
|
else if ([self.description hasPrefix:@"-- "])
|
|
title = [self.description substringFromIndex:[@"-- " length]];
|
|
else if ([self.description hasPrefix:@"--left-right "])
|
|
title = [self.description substringFromIndex:[@"--left-right " length]];
|
|
else
|
|
title = self.description;
|
|
|
|
return [NSString stringWithFormat:@"\"%@\"", title];
|
|
}
|
|
|
|
- (BOOL) hasPathLimiter;
|
|
{
|
|
for (NSString* param in parameters)
|
|
if ([param isEqualToString:@"--"])
|
|
return YES;
|
|
return NO;
|
|
}
|
|
|
|
- (BOOL) hasLeftRight
|
|
{
|
|
for (NSString* param in parameters)
|
|
if ([param isEqualToString:@"--left-right"])
|
|
return YES;
|
|
return NO;
|
|
}
|
|
|
|
- (BOOL) isEqualTo: (PBGitRevSpecifier*) other
|
|
{
|
|
if ([self isSimpleRef] ^ [other isSimpleRef])
|
|
return NO;
|
|
|
|
if ([self isSimpleRef])
|
|
return [[[self parameters] objectAtIndex: 0] isEqualToString: [other.parameters objectAtIndex: 0]];
|
|
|
|
return ([[parameters componentsJoinedByString:@" "] isEqualToString: [other.parameters componentsJoinedByString:@" "]] &&
|
|
(!description || [description isEqualToString:other.description]));
|
|
}
|
|
|
|
- (BOOL) isAllBranchesRev
|
|
{
|
|
return [self isEqualTo:[PBGitRevSpecifier allBranchesRevSpec]];
|
|
}
|
|
|
|
- (BOOL) isLocalBranchesRev
|
|
{
|
|
return [self isEqualTo:[PBGitRevSpecifier localBranchesRevSpec]];
|
|
}
|
|
|
|
- (void) encodeWithCoder:(NSCoder *)coder
|
|
{
|
|
[coder encodeObject:description forKey:@"Description"];
|
|
[coder encodeObject:parameters forKey:@"Parameters"];
|
|
}
|
|
@end
|