Skip to content

Commit 8e94918

Browse files
committed
Add a PBGitRef, a class to represent refs
1 parent f631f54 commit 8e94918

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

GitX.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
F58A8F280E043698007E3FC0 /* commits.css in Resources */ = {isa = PBXBuildFile; fileRef = F58A8F270E043698007E3FC0 /* commits.css */; };
3939
F5945E170E02B0C200706420 /* PBGitRepository.m in Sources */ = {isa = PBXBuildFile; fileRef = F5945E160E02B0C200706420 /* PBGitRepository.m */; };
4040
F5B721C40E05CF7E00AF29DC /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F5B721C20E05CF7E00AF29DC /* MainMenu.xib */; };
41+
F5C007750E731B48007B84B2 /* PBGitRef.m in Sources */ = {isa = PBXBuildFile; fileRef = F5C007740E731B48007B84B2 /* PBGitRef.m */; };
4142
F5C6F68D0E65FF9300478D97 /* PBGitLane.m in Sources */ = {isa = PBXBuildFile; fileRef = F5C6F68C0E65FF9300478D97 /* PBGitLane.m */; };
4243
F5DFFA6C0E075D8800617813 /* PBEasyFS.m in Sources */ = {isa = PBXBuildFile; fileRef = F5DFFA6B0E075D8800617813 /* PBEasyFS.m */; };
4344
F5FF4E180E0829C20006317A /* PBGitRevList.m in Sources */ = {isa = PBXBuildFile; fileRef = F5FF4E170E0829C20006317A /* PBGitRevList.m */; };
@@ -107,6 +108,8 @@
107108
F5945E150E02B0C200706420 /* PBGitRepository.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitRepository.h; sourceTree = "<group>"; };
108109
F5945E160E02B0C200706420 /* PBGitRepository.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitRepository.m; sourceTree = "<group>"; };
109110
F5B721C30E05CF7E00AF29DC /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = "<group>"; };
111+
F5C007730E731B48007B84B2 /* PBGitRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitRef.h; sourceTree = "<group>"; };
112+
F5C007740E731B48007B84B2 /* PBGitRef.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitRef.m; sourceTree = "<group>"; };
110113
F5C6F68B0E65FF9300478D97 /* PBGitLane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitLane.h; sourceTree = "<group>"; };
111114
F5C6F68C0E65FF9300478D97 /* PBGitLane.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitLane.m; sourceTree = "<group>"; };
112115
F5DFFA6A0E075D8800617813 /* PBEasyFS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBEasyFS.h; sourceTree = "<group>"; };
@@ -305,6 +308,8 @@
305308
F5C6F6750E65FE2B00478D97 /* Graphing */ = {
306309
isa = PBXGroup;
307310
children = (
311+
F5C007730E731B48007B84B2 /* PBGitRef.h */,
312+
F5C007740E731B48007B84B2 /* PBGitRef.m */,
308313
F50FE0E10E07BE9600854FCD /* PBGitRevisionCell.h */,
309314
F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */,
310315
F56CC7270E65E0AD004307B4 /* PBGitGraphLine.h */,
@@ -419,6 +424,7 @@
419424
F56CC7290E65E0AD004307B4 /* PBGitGraphLine.m in Sources */,
420425
F56CC7320E65E0E5004307B4 /* PBGraphCellInfo.m in Sources */,
421426
F5C6F68D0E65FF9300478D97 /* PBGitLane.m in Sources */,
427+
F5C007750E731B48007B84B2 /* PBGitRef.m in Sources */,
422428
);
423429
runOnlyForDeploymentPostprocessing = 0;
424430
};

PBGitRef.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// PBGitRef.h
3+
// GitX
4+
//
5+
// Created by Pieter de Bie on 06-09-08.
6+
// Copyright 2008 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import <Cocoa/Cocoa.h>
10+
11+
12+
@interface PBGitRef : NSObject {
13+
NSString* ref;
14+
}
15+
16+
- (NSString*) shortName;
17+
- (NSString*) type;
18+
+ (PBGitRef*) refFromString: (NSString*) s;
19+
- (PBGitRef*) initWithString: (NSString*) s;
20+
@property(readonly) NSString* ref;
21+
22+
@end

PBGitRef.m

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//
2+
// PBGitRef.m
3+
// GitX
4+
//
5+
// Created by Pieter de Bie on 06-09-08.
6+
// Copyright 2008 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import "PBGitRef.h"
10+
11+
12+
@implementation PBGitRef
13+
14+
@synthesize ref;
15+
- (NSString*) shortName
16+
{
17+
if ([self type])
18+
return [ref substringFromIndex:[[self type] length] + 7];
19+
return ref;
20+
}
21+
22+
- (NSString*) type
23+
{
24+
if ([ref hasPrefix:@"refs/heads"])
25+
return @"head";
26+
if ([ref hasPrefix:@"refs/tags"])
27+
return @"tag";
28+
if ([ref hasPrefix:@"refs/remotes"])
29+
return @"remote";
30+
return nil;
31+
}
32+
33+
+ (PBGitRef*) refFromString: (NSString*) s
34+
{
35+
return [[PBGitRef alloc] initWithString:s];
36+
}
37+
38+
- (PBGitRef*) initWithString: (NSString*) s
39+
{
40+
ref = s;
41+
return self;
42+
}
43+
44+
@end

0 commit comments

Comments
 (0)