Skip to content

Commit 83e7c42

Browse files
encode-zzbrotherbard
authored andcommitted
Highlight the current commit with an orange circle
1 parent 2ad624f commit 83e7c42

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

PBGitRepository.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) {
5050
NSMutableDictionary *refs;
5151

5252
PBGitRevSpecifier *_headRef; // Caching
53+
NSString* _headSha;
5354
}
5455

5556
- (void) cloneRepositoryToPath:(NSString *)path bare:(BOOL)isBare;

PBGitRepository.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ - (void) addRef: (PBGitRef *) ref fromParameters: (NSArray *) components
234234
- (void) reloadRefs
235235
{
236236
_headRef = nil;
237+
_headSha = nil;
237238

238239
refs = [NSMutableDictionary dictionary];
239240
NSMutableArray *oldBranches = [branches mutableCopy];
@@ -287,12 +288,17 @@ - (PBGitRevSpecifier *)headRef
287288
else
288289
_headRef = [[PBGitRevSpecifier alloc] initWithRef:[PBGitRef refFromString:@"HEAD"]];
289290

291+
_headSha = [self shaForRef:[_headRef ref]];
292+
290293
return _headRef;
291294
}
292295

293296
- (NSString *) headSHA
294297
{
295-
return [self shaForRef:[[self headRef] ref]];
298+
if (! _headSha)
299+
[self headRef];
300+
301+
return _headSha;
296302
}
297303

298304
- (PBGitCommit *) headCommit

PBGitRevisionCell.m

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ - (void) drawLineFromColumn: (int) from toColumn: (int) to inRect: (NSRect) r of
5454

5555
}
5656

57+
- (BOOL) isCurrentCommit
58+
{
59+
NSString* thisSha = [self.objectValue realSha];
60+
61+
PBGitRepository* repository = [self.objectValue repository];
62+
NSString* currentSha = [repository headSHA];
63+
64+
return [ currentSha isEqualToString : thisSha ];
65+
}
66+
5767
- (void) drawCircleInRect: (NSRect) r
5868
{
5969

@@ -71,7 +81,13 @@ - (void) drawCircleInRect: (NSRect) r
7181
[path fill];
7282

7383
NSRect smallOval = { columnOrigin.x - 3, columnOrigin.y + r.size.height * 0.5 - 3, 6, 6};
74-
[[NSColor whiteColor] set];
84+
85+
if ( [self isCurrentCommit ] ) {
86+
[[NSColor colorWithCalibratedRed: 0Xfc/256.0 green:0Xa6/256.0 blue: 0X4f/256.0 alpha: 1.0] set];
87+
} else {
88+
[[NSColor whiteColor] set];
89+
}
90+
7591
path = [NSBezierPath bezierPathWithOvalInRect:smallOval];
7692
[path fill];
7793
}

0 commit comments

Comments
 (0)