mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Add Pull to the contextual menus for refs
This commit is contained in:
@@ -30,6 +30,7 @@ extern NSString* PBGitRepositoryErrorDomain;
|
||||
}
|
||||
|
||||
- (void) beginFetchFromRemoteForRef:(PBGitRef *)ref;
|
||||
- (void) beginPullFromRemote:(PBGitRef *)remoteRef forRef:(PBGitRef *)ref;
|
||||
- (BOOL) checkoutRefish:(id <PBGitRefish>)ref;
|
||||
- (BOOL) checkoutFiles:(NSArray *)files fromRefish:(id <PBGitRefish>)ref;
|
||||
- (BOOL) mergeWithRefish:(id <PBGitRefish>)ref;
|
||||
|
||||
@@ -504,6 +504,45 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
|
||||
[PBRemoteProgressSheet beginRemoteProgressSheetForArguments:arguments title:title description:description inRepository:self];
|
||||
}
|
||||
|
||||
- (void) beginPullFromRemote:(PBGitRef *)remoteRef forRef:(PBGitRef *)ref
|
||||
{
|
||||
NSMutableArray *arguments = [NSMutableArray arrayWithObject:@"pull"];
|
||||
|
||||
// a nil remoteRef means lookup the ref's default remote
|
||||
if (!remoteRef || ![remoteRef isRemote]) {
|
||||
NSError *error = nil;
|
||||
remoteRef = [self remoteRefForBranch:ref error:&error];
|
||||
if (!remoteRef) {
|
||||
if (error)
|
||||
[self.windowController showErrorSheet:error];
|
||||
return;
|
||||
}
|
||||
}
|
||||
NSString *remoteName = [remoteRef remoteName];
|
||||
[arguments addObject:remoteName];
|
||||
|
||||
NSString *branchName = nil;
|
||||
NSString *refSpec = nil;
|
||||
if ([ref isRemoteBranch]) {
|
||||
branchName = [ref shortName];
|
||||
refSpec = [ref remoteBranchName];
|
||||
}
|
||||
else if ([ref isRemote] || !ref) {
|
||||
branchName = @"all tracking branches";
|
||||
}
|
||||
else {
|
||||
branchName = [ref shortName];
|
||||
refSpec = [NSString stringWithFormat:@"%@:%@", branchName, branchName];
|
||||
}
|
||||
if (refSpec)
|
||||
[arguments addObject:refSpec];
|
||||
|
||||
NSString *headRefName = [[[self headRef] ref] shortName];
|
||||
NSString *description = [NSString stringWithFormat:@"Pulling %@ from %@ and updating %@", branchName, remoteName, headRefName];
|
||||
NSString *title = @"Pulling from remote";
|
||||
[PBRemoteProgressSheet beginRemoteProgressSheetForArguments:arguments title:title description:description inRepository:self];
|
||||
}
|
||||
|
||||
- (BOOL) checkoutRefish:(id <PBGitRefish>)ref
|
||||
{
|
||||
NSString *refName = nil;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
}
|
||||
|
||||
- (void) fetchRemote:(PBRefMenuItem *)sender;
|
||||
- (void) pullRemote:(PBRefMenuItem *)sender;
|
||||
|
||||
- (void) checkout:(PBRefMenuItem *)sender;
|
||||
- (void) merge:(PBRefMenuItem *)sender;
|
||||
|
||||
@@ -51,6 +51,15 @@
|
||||
}
|
||||
|
||||
|
||||
#pragma mark Pull
|
||||
|
||||
- (void) pullRemote:(PBRefMenuItem *)sender
|
||||
{
|
||||
id <PBGitRefish> refish = [sender refish];
|
||||
[historyController.repository beginPullFromRemote:nil forRef:refish];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark Merge
|
||||
|
||||
- (void) merge:(PBRefMenuItem *)sender
|
||||
|
||||
@@ -83,6 +83,11 @@
|
||||
NSString *fetchTitle = hasRemote ? [NSString stringWithFormat:@"Fetch %@", remoteName] : @"Fetch";
|
||||
[items addObject:[PBRefMenuItem itemWithTitle:fetchTitle action:@selector(fetchRemote:) enabled:hasRemote]];
|
||||
|
||||
// pull
|
||||
NSString *pullRemoteName = [ref isRemoteBranch] ? [ref shortName] : remoteName;
|
||||
NSString *pullTitle = hasRemote ? [NSString stringWithFormat:@"Pull %@ and update %@", pullRemoteName, headRefName] : @"Pull";
|
||||
[items addObject:[PBRefMenuItem itemWithTitle:pullTitle action:@selector(pullRemote:) enabled:hasRemote]];
|
||||
|
||||
// delete ref
|
||||
[items addObject:[PBRefMenuItem separatorItem]];
|
||||
NSString *deleteTitle = [NSString stringWithFormat:@"Delete %@…", targetRefName];
|
||||
|
||||
Reference in New Issue
Block a user