mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Add Fetch to the contextual menus for refs
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
IBOutlet NSPopUpButton *branchPopUp;
|
||||
}
|
||||
|
||||
- (void) fetchRemote:(PBRefMenuItem *)sender;
|
||||
|
||||
- (void) checkout:(PBRefMenuItem *)sender;
|
||||
- (void) merge:(PBRefMenuItem *)sender;
|
||||
- (void) cherryPick:(PBRefMenuItem *)sender;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user