Skip to content

Commit 4b0be0b

Browse files
committed
Merge branch 'master' into issues/239
Conflicts: English.lproj/MainMenu.xib GitX.xcodeproj/project.pbxproj Resources/XIBs/PBGitCommitView.xib
2 parents 9588379 + 7dc23e5 commit 4b0be0b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+755
-1152
lines changed

Classes/Controllers/PBGitHistoryController.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ - (void)awakeFromNib
100100
// listen for updates
101101
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_repositoryUpdatedNotification:) name:PBGitRepositoryEventNotification object:repository];
102102

103+
__weak PBGitHistoryController *weakSelf = self;
104+
commitList.findPanelActionBlock = ^(id sender){
105+
PBGitHistoryController *controller = weakSelf;
106+
if (!controller) {
107+
return;
108+
}
109+
[controller.view.window makeFirstResponder:controller->searchField];
110+
};
111+
103112
[super awakeFromNib];
104113
}
105114

Classes/NSColor+RGB.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// NSColor+RGB.h
3+
// GitX
4+
//
5+
// Created by Rowan James on 18/08/13.
6+
//
7+
//
8+
9+
#import <Cocoa/Cocoa.h>
10+
11+
@interface NSColor (RGB)
12+
13+
+ (NSColor *)colorWithR:(uint8_t)r G:(uint8_t)g B:(uint8_t)b;
14+
15+
@end

Classes/NSColor+RGB.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// NSColor+RGB.m
3+
// GitX
4+
//
5+
// Created by Rowan James on 18/08/13.
6+
//
7+
//
8+
9+
#import "NSColor+RGB.h"
10+
11+
@implementation NSColor (RGB)
12+
13+
+ (NSColor *)colorWithR:(uint8_t)r G:(uint8_t)g B:(uint8_t)b
14+
{
15+
const CGFloat MAX_RGB = 255.0;
16+
NSColor *result = [NSColor colorWithCalibratedRed:(r/MAX_RGB) green:(g/MAX_RGB) blue:(b/MAX_RGB) alpha:1];
17+
return result;
18+
}
19+
20+
@end

Classes/PBCommitList.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
@class PBWebHistoryController;
1414

15+
typedef void(^PBFindPanelActionBlock)(id sender);
16+
1517
@interface PBCommitList : NSTableView {
1618
IBOutlet WebView* webView;
1719
IBOutlet PBWebHistoryController *webController;
@@ -24,4 +26,5 @@
2426

2527
@property (readonly) NSPoint mouseDownPoint;
2628
@property (assign) BOOL useAdjustScroll;
29+
@property (copy) PBFindPanelActionBlock findPanelActionBlock;
2730
@end

Classes/PBCommitList.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,13 @@ - (void)highlightSelectionInClipRect:(NSRect)tableViewClipRect
185185
[super highlightSelectionInClipRect:tableViewClipRect];
186186
}
187187

188+
189+
- (IBAction)performFindPanelAction:(id)sender
190+
{
191+
PBFindPanelActionBlock block = self.findPanelActionBlock;
192+
if (block) {
193+
block(sender);
194+
}
195+
}
196+
188197
@end

Classes/Views/PBGitRevisionCell.m

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#import "RoundedRectangle.h"
1212
#import "GitXTextFieldCell.h"
1313

14+
const int COLUMN_WIDTH = 10;
15+
1416
@implementation PBGitRevisionCell
1517

1618

@@ -39,12 +41,10 @@ + (NSArray *)laneColors
3941

4042
- (void) drawLineFromColumn: (int) from toColumn: (int) to inRect: (NSRect) r offset: (int) offset color: (int) c
4143
{
42-
43-
int columnWidth = 10;
4444
NSPoint origin = r.origin;
4545

46-
NSPoint source = NSMakePoint(origin.x + columnWidth* from, origin.y + offset);
47-
NSPoint center = NSMakePoint( origin.x + columnWidth * to, origin.y + r.size.height * 0.5 + 0.5);
46+
NSPoint source = NSMakePoint(origin.x + COLUMN_WIDTH * from, origin.y + offset);
47+
NSPoint center = NSMakePoint( origin.x + COLUMN_WIDTH * to, origin.y + r.size.height * 0.5 + 0.5);
4848

4949
NSArray* colors = [PBGitRevisionCell laneColors];
5050
[(NSColor*)[colors objectAtIndex: (c % [colors count])] set];
@@ -72,9 +72,8 @@ - (void) drawCircleInRect: (NSRect) r
7272
{
7373

7474
int c = cellInfo.position;
75-
int columnWidth = 10;
7675
NSPoint origin = r.origin;
77-
NSPoint columnOrigin = { origin.x + columnWidth * c, origin.y};
76+
NSPoint columnOrigin = { origin.x + COLUMN_WIDTH * c, origin.y};
7877

7978
NSRect oval = { columnOrigin.x - 5, columnOrigin.y + r.size.height * 0.5 - 5, 10, 10};
8079

@@ -232,7 +231,7 @@ - (void) drawWithFrame: (NSRect) rect inView:(NSView *)view
232231
cellInfo = [self.objectValue lineInfo];
233232

234233
if (cellInfo && ![controller hasNonlinearPath]) {
235-
float pathWidth = 10 + 10 * cellInfo.numColumns;
234+
float pathWidth = 10 + COLUMN_WIDTH * cellInfo.numColumns;
236235

237236
NSRect ownRect;
238237
NSDivideRect(rect, &ownRect, &rect, pathWidth, NSMinXEdge);

Classes/Views/PBRefMenuItem.m

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ + (NSArray *) defaultMenuItemsForRef:(PBGitRef *)ref inRepository:(PBGitReposito
8484
BOOL isDetachedHead = (isHead && [headRefName isEqualToString:@"HEAD"]);
8585

8686
NSString *remoteName = [ref remoteName];
87-
if (!remoteName && [ref isBranch])
87+
if (!remoteName && [ref isBranch]) {
8888
remoteName = [[repo remoteRefForBranch:ref error:NULL] remoteName];
89+
}
8990
BOOL hasRemote = (remoteName ? YES : NO);
9091
BOOL isRemote = ([ref isRemote] && ![ref isRemoteBranch]);
9192

@@ -168,8 +169,12 @@ + (NSArray *) defaultMenuItemsForRef:(PBGitRef *)ref inRepository:(PBGitReposito
168169

169170
// delete ref
170171
[items addObject:[PBRefMenuItem separatorItem]];
171-
NSString *deleteTitle = [NSString stringWithFormat:@"Delete %@", targetRefName];
172-
[items addObject:[PBRefMenuItem itemWithTitle:deleteTitle action:@selector(showDeleteRefSheet:) enabled:!isDetachedHead]];
172+
{
173+
NSString *deleteTitle = [NSString stringWithFormat:@"Delete %@", targetRefName];
174+
BOOL deleteEnabled = !(isDetachedHead || [ref isRemote] || isHead);
175+
PBRefMenuItem *deleteItem = [PBRefMenuItem itemWithTitle:deleteTitle action:@selector(showDeleteRefSheet:) enabled:deleteEnabled];
176+
[items addObject:deleteItem];
177+
}
173178

174179
for (PBRefMenuItem *item in items) {
175180
[item setTarget:target];

Classes/git/PBGitCommit.m

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ - (NSArray *)parents
6363
NSArray *gtParents = self.gtCommit.parents;
6464
NSMutableArray *parents = [NSMutableArray arrayWithCapacity:gtParents.count];
6565
for (GTCommit *parent in gtParents) {
66-
[parents addObject:[PBGitSHA shaWithString:parent.sha]];
66+
[parents addObject:[PBGitSHA shaWithString:parent.SHA]];
6767
}
6868
self.parents = parents;
6969
}
@@ -84,11 +84,7 @@ - (NSString *)author
8484
- (NSString *)committer
8585
{
8686
GTSignature *sig = self.gtCommit.committer;
87-
if (![sig isEqual:self.gtCommit.author]) {
88-
return sig.name
89-
;
90-
}
91-
return nil;
87+
return sig.name;
9288
}
9389

9490
- (NSString *)SVNRevision
@@ -119,9 +115,9 @@ - (NSString *)SVNRevision
119115
- (PBGitSHA *)sha
120116
{
121117
if (!self->_sha) {
122-
const git_oid *oid = git_commit_id(self.gtCommit.git_commit);
118+
const git_oid *oid = self.gtCommit.OID.git_oid;
123119
if (oid) {
124-
PBGitSHA *newSha = [PBGitSHA shaWithOID:*oid];
120+
PBGitSHA *newSha = [PBGitSHA shaWithOID:oid];
125121
self.sha = newSha;
126122
}
127123
}
@@ -130,7 +126,7 @@ - (PBGitSHA *)sha
130126

131127
- (NSString *)realSha
132128
{
133-
return self.gtCommit.sha;
129+
return self.gtCommit.SHA;
134130
}
135131

136132
- (BOOL) isOnSameBranchAs:(PBGitCommit *)otherCommit
@@ -214,12 +210,12 @@ - (BOOL) hasRef:(PBGitRef *)ref
214210

215211
- (NSMutableArray *)refs
216212
{
217-
return [[self.repository refs] objectForKey:self.sha];
213+
return self.repository.refs[self.sha];
218214
}
219215

220216
- (void) setRefs:(NSMutableArray *)refs
221217
{
222-
[[self.repository refs] setObject:refs forKey:self.sha];
218+
self.repository.refs[self.sha] = [NSMutableArray arrayWithArray:refs];
223219
}
224220

225221

@@ -242,7 +238,7 @@ - (NSString *) refishName
242238

243239
- (NSString *) shortName
244240
{
245-
return self.gtCommit.shortSha;
241+
return self.gtCommit.shortSHA;
246242
}
247243

248244
- (NSString *) refishType

Classes/git/PBGitRef.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ extern NSString * const kGitXRemoteRefPrefix;
2222
extern NSString * const kGitXStashRefPrefix;
2323

2424

25-
@interface PBGitRef : NSObject <PBGitRefish> {
26-
NSString* ref;
27-
}
25+
@interface PBGitRef : NSObject <PBGitRefish>
2826

2927
// <PBGitRefish>
3028
- (NSString *) refishName;
@@ -49,6 +47,7 @@ extern NSString * const kGitXStashRefPrefix;
4947

5048
+ (PBGitRef*) refFromString: (NSString*) s;
5149
- (PBGitRef*) initWithString: (NSString*) s;
52-
@property(readonly) NSString* ref;
50+
51+
@property(nonatomic, strong, readonly) NSString* ref;
5352

5453
@end

Classes/git/PBGitRef.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
NSString * const kGitXRemoteRefPrefix = @"refs/remotes/";
2121
NSString * const kGitXStashRefPrefix = @"refs/stash@";
2222

23+
@interface PBGitRef ()
24+
25+
@property(nonatomic, strong) NSString* ref;
26+
27+
@end
2328

2429
@implementation PBGitRef
2530

@@ -118,6 +123,10 @@ + (PBGitRef*) refFromString: (NSString*) s
118123

119124
- (PBGitRef*) initWithString: (NSString*) s
120125
{
126+
self = [super init];
127+
if (!self) {
128+
return nil;
129+
}
121130
ref = s;
122131
return self;
123132
}

0 commit comments

Comments
 (0)