mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
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:
@@ -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;
|
||||
|
||||
@@ -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
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user