Add Cherry Pick to contextual menu for commits.

This commit is contained in:
Nathan Kinsinger
2009-12-27 13:29:50 -07:00
parent e2ccfe6fce
commit e50ddbc503
5 changed files with 36 additions and 0 deletions
+1
View File
@@ -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;
+21
View File
@@ -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)
+1
View File
@@ -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;
+9
View File
@@ -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
+4
View File
@@ -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];