cherry pick done

This commit is contained in:
Peter Cottle 2012-11-04 17:12:09 -08:00
parent d4946143a8
commit e021e6fd9b
2 changed files with 23 additions and 2 deletions

View file

@ -118,7 +118,8 @@ var Command = Backbone.Model.extend({
log: /^log($|\s)/, log: /^log($|\s)/,
merge: /^merge($|\s)/, merge: /^merge($|\s)/,
show: /^show($|\s)/, show: /^show($|\s)/,
status: /^status($|\s)/ status: /^status($|\s)/,
'cherry-pick': /^cherry-pick($|\s)/
}; };
}, },
@ -258,6 +259,7 @@ OptionParser.prototype.getMasterOptionMap = function() {
status: {}, status: {},
log: {}, log: {},
add: {}, add: {},
'cherry-pick': {},
branch: { branch: {
'-d': false, '-d': false,
'-D': false, '-D': false,

View file

@ -455,6 +455,24 @@ GitEngine.prototype.reset = function(target) {
this.setTargetLocation('HEAD', this.getCommitFromRef(target)); this.setTargetLocation('HEAD', this.getCommitFromRef(target));
}; };
GitEngine.prototype.cherrypickStarter = function() {
this.validateArgBounds(this.generalArgs, 1, 1);
var newCommit = this.cherrypick(this.generalArgs[0]);
animationFactory.genCommitBirthAnimation(this.animationQueue, newCommit, this.gitVisuals);
};
GitEngine.prototype.cherrypick = function(ref) {
var commit = this.getCommitFromRef(ref);
// alter the ID slightly
var id = this.rebaseAltID(commit.get('id'));
// now commit with that id onto HEAD
var newCommit = this.makeCommit([this.getCommitFromRef('HEAD')], id);
this.setTargetLocation(this.HEAD, newCommit);
return newCommit;
};
GitEngine.prototype.commitStarter = function() { GitEngine.prototype.commitStarter = function() {
this.acceptNoGeneralArgs(); this.acceptNoGeneralArgs();
if (this.commandOptions['-am'] && ( if (this.commandOptions['-am'] && (
@ -1244,7 +1262,8 @@ GitEngine.prototype.dispatch = function(command, callback) {
command.set('status', 'processing'); command.set('status', 'processing');
try { try {
this[command.get('method') + 'Starter'](); var methodName = command.get('method').replace(/-/g, '') + 'Starter';
this[methodName]();
} catch (err) { } catch (err) {
if (err instanceof GitError || if (err instanceof GitError ||
err instanceof CommandResult) { err instanceof CommandResult) {