mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
PBGitRepository: Add method to remove branch
This adds a removeBranch method similar to the addBranch method. It calls these methods when a branch is created/deleted in the UI, avoiding the cost of simply calling refresh afterwards. Signed-off-by: Johannes Gilger <heipei@hackvalue.de>
This commit is contained in:
committed by
Pieter de Bie
parent
7b6393570f
commit
64b977e9c8
@@ -51,6 +51,7 @@ extern NSString* PBGitRepositoryErrorDomain;
|
||||
|
||||
- (void) readCurrentBranch;
|
||||
- (PBGitRevSpecifier*) addBranch: (PBGitRevSpecifier*) rev;
|
||||
- (BOOL)removeBranch:(PBGitRevSpecifier *)rev;
|
||||
|
||||
- (NSString*) parseSymbolicReference:(NSString*) ref;
|
||||
- (NSString*) parseReference:(NSString*) ref;
|
||||
|
||||
@@ -294,6 +294,19 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
|
||||
[self didChangeValueForKey:@"branches"];
|
||||
return rev;
|
||||
}
|
||||
|
||||
- (BOOL)removeBranch:(PBGitRevSpecifier *)rev
|
||||
{
|
||||
for (PBGitRevSpecifier *r in branches) {
|
||||
if ([rev isEqualTo:r]) {
|
||||
[self willChangeValueForKey:@"branches"];
|
||||
[branches removeObject:r];
|
||||
[self didChangeValueForKey:@"branches"];
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
- (void) readCurrentBranch
|
||||
{
|
||||
|
||||
+2
-2
@@ -49,7 +49,7 @@
|
||||
NSLog(@"Removing ref failed!");
|
||||
return;
|
||||
}
|
||||
|
||||
[historyController.repository removeBranch:[[PBGitRevSpecifier alloc] initWithRef:[sender ref]]];
|
||||
[[sender commit] removeRef:[sender ref]];
|
||||
[commitController rearrangeObjects];
|
||||
}
|
||||
@@ -208,7 +208,7 @@
|
||||
[errorMessage setStringValue:@"Branch exists"];
|
||||
return;
|
||||
}
|
||||
|
||||
[historyController.repository addBranch:[[PBGitRevSpecifier alloc] initWithRef:[PBGitRef refFromString:branchName]]];
|
||||
[self closeSheet:sender];
|
||||
[commit addRef:[PBGitRef refFromString:branchName]];
|
||||
[commitController rearrangeObjects];
|
||||
|
||||
Reference in New Issue
Block a user