mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Add branch control to the PBGitRepository
This allows you to add and select specific branches
This commit is contained in:
+5
-2
@@ -8,12 +8,13 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "PBGitRevList.h"
|
||||
#import "PBGitRevSpecifier.h"
|
||||
|
||||
extern NSString* PBGitRepositoryErrorDomain;
|
||||
|
||||
@interface PBGitRepository : NSDocument {
|
||||
PBGitRevList* revisionList;
|
||||
NSArray* branches;
|
||||
NSMutableArray* branches;
|
||||
NSIndexSet* currentBranch;
|
||||
NSDictionary* refs;
|
||||
}
|
||||
@@ -25,6 +26,8 @@ extern NSString* PBGitRepositoryErrorDomain;
|
||||
|
||||
- (void) readRefs;
|
||||
- (void) readCurrentBranch;
|
||||
- (void) addBranch: (PBGitRevSpecifier*) rev;
|
||||
- (void) selectBranch: (PBGitRevSpecifier*) rev;
|
||||
|
||||
- (NSString*) parseSymbolicReference:(NSString*) ref;
|
||||
- (NSString*) parseReference:(NSString*) ref;
|
||||
@@ -35,7 +38,7 @@ extern NSString* PBGitRepositoryErrorDomain;
|
||||
- (id) initWithURL: (NSURL*) path andArguments:(NSArray*) array;
|
||||
|
||||
@property (retain) PBGitRevList* revisionList;
|
||||
@property (assign) NSArray* branches;
|
||||
@property (assign) NSMutableArray* branches;
|
||||
@property (assign) NSIndexSet* currentBranch;
|
||||
@property (assign) NSDictionary* refs;
|
||||
@end
|
||||
|
||||
@@ -183,6 +183,23 @@ static NSString* gitPath;
|
||||
self.refs = newRefs;
|
||||
}
|
||||
|
||||
- (void) addBranch: (PBGitRevSpecifier*) rev
|
||||
{
|
||||
[branches addObject: rev];
|
||||
}
|
||||
|
||||
- (void) selectBranch: (PBGitRevSpecifier*) rev
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < [branches count]; i++) {
|
||||
PBGitRevSpecifier* aRev = [branches objectAtIndex:i];
|
||||
if (rev == aRev) {
|
||||
self.currentBranch = [NSIndexSet indexSetWithIndex:i];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) readCurrentBranch
|
||||
{
|
||||
NSString* branch = [self parseSymbolicReference: @"HEAD"];
|
||||
|
||||
Reference in New Issue
Block a user