Add support for removing refs

This is somewhat hackish, in that it reloads all commits after deleting
a ref, but at least it works
This commit is contained in:
Pieter de Bie
2008-09-22 21:12:26 +02:00
parent faef971e18
commit ea3cd7287c
3 changed files with 33 additions and 3 deletions
+2
View File
@@ -28,6 +28,8 @@ extern NSString* PBGitRepositoryErrorDomain;
- (BOOL) reloadRefs;
- (void) addRef:(PBGitRef *)ref fromParameters:(NSArray *)params;
- (BOOL) removeRef:(NSString *)ref;
- (void) readCurrentBranch;
- (PBGitRevSpecifier*) addBranch: (PBGitRevSpecifier*) rev;
- (void) selectBranch: (PBGitRevSpecifier*) rev;
+14
View File
@@ -307,4 +307,18 @@ static NSString* gitPath;
return nil;
}
- (BOOL) removeRef:(NSString *)ref
{
int i;
[self outputForArguments:[NSArray arrayWithObjects:@"branch", @"-D", ref, nil] retValue:&i];
if (i == 0) {
// Todo: We can do better than this!
[self reloadRefs];
[revisionList reload];
return YES;
}
return NO;
}
@end
+17 -3
View File
@@ -7,6 +7,15 @@
//
#import "PBWebGitController.h"
@interface RefMenuItem : NSMenuItem
{
NSString *ref;
}
@property (copy) NSString *ref;
@end
@implementation RefMenuItem
@synthesize ref;
@end
@implementation PBWebGitController
@@ -95,9 +104,13 @@
return NO;
}
- (void) removeRef: (id) sender
- (void) removeRef:(RefMenuItem *)sender
{
NSLog(@"Removing refs is not yet supported");
NSLog(@"Removing ref: %@", [sender ref]);
if ([historyController.repository removeRef: [sender ref]])
NSLog(@"Deletion succesful!");
else
NSLog(@"Deletion failed!");
}
- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems {
@@ -108,8 +121,9 @@
// Every ref has a class name of 'refs' and some other class. We check on that to see if we pressed on a ref.
if ([[node className] hasPrefix:@"refs "]) {
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@"Remove" action:@selector(removeRef:) keyEquivalent: @""];
RefMenuItem *item = [[RefMenuItem alloc] initWithTitle:@"Remove" action:@selector(removeRef:) keyEquivalent: @""];
[item setTarget: self];
[item setRef: [[[node childNodes] item:0] textContent]];
return [NSArray arrayWithObject: item];
}