Add Fetch to the contextual menus for refs

This commit is contained in:
Nathan Kinsinger
2010-02-06 18:27:17 -07:00
parent 55973b4aff
commit 4654dc105f
5 changed files with 43 additions and 0 deletions
+1
View File
@@ -29,6 +29,7 @@ extern NSString* PBGitRepositoryErrorDomain;
PBGitRevSpecifier *_headRef; // Caching
}
- (void) beginFetchFromRemoteForRef:(PBGitRef *)ref;
- (BOOL) checkoutRefish:(id <PBGitRefish>)ref;
- (BOOL) checkoutFiles:(NSArray *)files fromRefish:(id <PBGitRefish>)ref;
- (BOOL) mergeWithRefish:(id <PBGitRefish>)ref;
+22
View File
@@ -15,6 +15,7 @@
#import "PBEasyPipe.h"
#import "PBGitRef.h"
#import "PBGitRevSpecifier.h"
#import "PBRemoteProgressSheet.h"
NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
@@ -482,6 +483,27 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
#pragma mark Repository commands
- (void) beginFetchFromRemoteForRef:(PBGitRef *)ref
{
NSMutableArray *arguments = [NSMutableArray arrayWithObject:@"fetch"];
if (![ref isRemote]) {
NSError *error = nil;
ref = [self remoteRefForBranch:ref error:&error];
if (!ref) {
if (error)
[self.windowController showErrorSheet:error];
return;
}
}
NSString *remoteName = [ref remoteName];
[arguments addObject:remoteName];
NSString *description = [NSString stringWithFormat:@"Fetching all tracking branches from %@", remoteName];
NSString *title = @"Fetching from remote";
[PBRemoteProgressSheet beginRemoteProgressSheetForArguments:arguments title:title description:description inRepository:self];
}
- (BOOL) checkoutRefish:(id <PBGitRefish>)ref
{
NSString *refName = nil;
+2
View File
@@ -23,6 +23,8 @@
IBOutlet NSPopUpButton *branchPopUp;
}
- (void) fetchRemote:(PBRefMenuItem *)sender;
- (void) checkout:(PBRefMenuItem *)sender;
- (void) merge:(PBRefMenuItem *)sender;
- (void) cherryPick:(PBRefMenuItem *)sender;
+12
View File
@@ -39,6 +39,18 @@
}
#pragma mark Fetch
- (void) fetchRemote:(PBRefMenuItem *)sender
{
id <PBGitRefish> refish = [sender refish];
if ([refish refishType] == kGitXCommitType)
return;
[historyController.repository beginFetchFromRemoteForRef:refish];
}
#pragma mark Merge
- (void) merge:(PBRefMenuItem *)sender
+6
View File
@@ -75,8 +75,14 @@
// rebase
NSString *rebaseTitle = isOnHeadBranch ? @"Rebase" : [NSString stringWithFormat:@"Rebase %@ on %@", headRefName, targetRefName];
[items addObject:[PBRefMenuItem itemWithTitle:rebaseTitle action:@selector(rebaseHeadBranch:) enabled:!isOnHeadBranch]];
[items addObject:[PBRefMenuItem separatorItem]];
}
// fetch
NSString *fetchTitle = hasRemote ? [NSString stringWithFormat:@"Fetch %@", remoteName] : @"Fetch";
[items addObject:[PBRefMenuItem itemWithTitle:fetchTitle action:@selector(fetchRemote:) enabled:hasRemote]];
// delete ref
[items addObject:[PBRefMenuItem separatorItem]];
NSString *deleteTitle = [NSString stringWithFormat:@"Delete %@…", targetRefName];