mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Highlight the current commit with an orange circle
This commit is contained in:
@@ -50,6 +50,7 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) {
|
||||
NSMutableDictionary *refs;
|
||||
|
||||
PBGitRevSpecifier *_headRef; // Caching
|
||||
NSString* _headSha;
|
||||
}
|
||||
|
||||
- (void) cloneRepositoryToPath:(NSString *)path bare:(BOOL)isBare;
|
||||
|
||||
+7
-1
@@ -234,6 +234,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
|
||||
- (void) reloadRefs
|
||||
{
|
||||
_headRef = nil;
|
||||
_headSha = nil;
|
||||
|
||||
refs = [NSMutableDictionary dictionary];
|
||||
NSMutableArray *oldBranches = [branches mutableCopy];
|
||||
@@ -287,12 +288,17 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
|
||||
else
|
||||
_headRef = [[PBGitRevSpecifier alloc] initWithRef:[PBGitRef refFromString:@"HEAD"]];
|
||||
|
||||
_headSha = [self shaForRef:[_headRef ref]];
|
||||
|
||||
return _headRef;
|
||||
}
|
||||
|
||||
- (NSString *) headSHA
|
||||
{
|
||||
return [self shaForRef:[[self headRef] ref]];
|
||||
if (! _headSha)
|
||||
[self headRef];
|
||||
|
||||
return _headSha;
|
||||
}
|
||||
|
||||
- (PBGitCommit *) headCommit
|
||||
|
||||
+17
-1
@@ -54,6 +54,16 @@
|
||||
|
||||
}
|
||||
|
||||
- (BOOL) isCurrentCommit
|
||||
{
|
||||
NSString* thisSha = [self.objectValue realSha];
|
||||
|
||||
PBGitRepository* repository = [self.objectValue repository];
|
||||
NSString* currentSha = [repository headSHA];
|
||||
|
||||
return [ currentSha isEqualToString : thisSha ];
|
||||
}
|
||||
|
||||
- (void) drawCircleInRect: (NSRect) r
|
||||
{
|
||||
|
||||
@@ -71,7 +81,13 @@
|
||||
[path fill];
|
||||
|
||||
NSRect smallOval = { columnOrigin.x - 3, columnOrigin.y + r.size.height * 0.5 - 3, 6, 6};
|
||||
[[NSColor whiteColor] set];
|
||||
|
||||
if ( [self isCurrentCommit ] ) {
|
||||
[[NSColor colorWithCalibratedRed: 0Xfc/256.0 green:0Xa6/256.0 blue: 0X4f/256.0 alpha: 1.0] set];
|
||||
} else {
|
||||
[[NSColor whiteColor] set];
|
||||
}
|
||||
|
||||
path = [NSBezierPath bezierPathWithOvalInRect:smallOval];
|
||||
[path fill];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user