mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Add Cherry Pick to contextual menu for commits.
This commit is contained in:
@@ -32,6 +32,7 @@ extern NSString* PBGitRepositoryErrorDomain;
|
||||
- (BOOL) checkoutRefish:(id <PBGitRefish>)ref;
|
||||
- (BOOL) checkoutFiles:(NSArray *)files fromRefish:(id <PBGitRefish>)ref;
|
||||
- (BOOL) mergeWithRefish:(id <PBGitRefish>)ref;
|
||||
- (BOOL) cherryPickRefish:(id <PBGitRefish>)ref;
|
||||
- (BOOL) createBranch:(NSString *)branchName atRefish:(id <PBGitRefish>)ref;
|
||||
- (BOOL) createTag:(NSString *)tagName message:(NSString *)message atRefish:(id <PBGitRefish>)commitSHA;
|
||||
- (BOOL) deleteRef:(PBGitRef *)ref;
|
||||
|
||||
@@ -494,6 +494,27 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) cherryPickRefish:(id <PBGitRefish>)ref
|
||||
{
|
||||
if (!ref)
|
||||
return NO;
|
||||
|
||||
NSString *refName = [ref refishName];
|
||||
|
||||
int retValue = 1;
|
||||
NSArray *arguments = [NSArray arrayWithObjects:@"cherry-pick", refName, nil];
|
||||
NSString *output = [self outputInWorkdirForArguments:arguments retValue:&retValue];
|
||||
if (retValue) {
|
||||
NSString *message = [NSString stringWithFormat:@"There was an error cherry picking the %@ '%@'.\n\nPerhaps your working directory is not clean?", [ref refishType], [ref shortName]];
|
||||
[self.windowController showErrorSheetTitle:@"Cherry pick failed!" message:message arguments:arguments output:output];
|
||||
return NO;
|
||||
}
|
||||
|
||||
[self reloadRefs];
|
||||
[self readCurrentBranch];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) createBranch:(NSString *)branchName atRefish:(id <PBGitRefish>)ref
|
||||
{
|
||||
if (!branchName || !ref)
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
- (void) checkout:(PBRefMenuItem *)sender;
|
||||
- (void) merge:(PBRefMenuItem *)sender;
|
||||
- (void) cherryPick:(PBRefMenuItem *)sender;
|
||||
- (void) createBranch:(PBRefMenuItem *)sender;
|
||||
- (void) copySHA:(PBRefMenuItem *)sender;
|
||||
- (void) copyPatch:(PBRefMenuItem *)sender;
|
||||
|
||||
@@ -57,6 +57,15 @@
|
||||
}
|
||||
|
||||
|
||||
#pragma mark Cherry Pick
|
||||
|
||||
- (void) cherryPick:(PBRefMenuItem *)sender
|
||||
{
|
||||
id <PBGitRefish> refish = [sender refish];
|
||||
[historyController.repository cherryPickRefish:refish];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark Create Branch
|
||||
|
||||
- (void) createBranch:(PBRefMenuItem *)sender
|
||||
|
||||
@@ -102,6 +102,10 @@
|
||||
NSString *mergeTitle = isOnHeadBranch ? @"Merge commit" : [NSString stringWithFormat:@"Merge commit into %@", headBranchName];
|
||||
[items addObject:[PBRefMenuItem itemWithTitle:mergeTitle action:@selector(merge:) enabled:!isOnHeadBranch]];
|
||||
|
||||
// cherry pick
|
||||
NSString *cherryPickTitle = isOnHeadBranch ? @"Cherry pick commit" : [NSString stringWithFormat:@"Cherry pick commit to %@", headBranchName];
|
||||
[items addObject:[PBRefMenuItem itemWithTitle:cherryPickTitle action:@selector(cherryPick:) enabled:!isOnHeadBranch]];
|
||||
|
||||
for (PBRefMenuItem *item in items) {
|
||||
[item setTarget:target];
|
||||
[item setRefish:commit];
|
||||
|
||||
Reference in New Issue
Block a user