mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-04 11:44:27 +02:00
awesome promise based interactive rebase with fail
This commit is contained in:
parent
79ee686721
commit
2b308e2ae9
14 changed files with 1731 additions and 296 deletions
1853
build/bundle.js
1853
build/bundle.js
File diff suppressed because it is too large
Load diff
|
@ -13,6 +13,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"backbone": "~0.9.9",
|
"backbone": "~0.9.9",
|
||||||
"underscore": "~1.4.3",
|
"underscore": "~1.4.3",
|
||||||
"jquery": "~1.8.3"
|
"jquery": "~1.8.3",
|
||||||
|
"q": "~0.8.11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
var Backbone;
|
|
||||||
// horrible hack to get localStorage Backbone plugin
|
// horrible hack to get localStorage Backbone plugin
|
||||||
if (!require('../util').isBrowser()) {
|
var Backbone = (!require('../util').isBrowser()) ? Backbone = require('backbone') : Backbone = window.Backbone;
|
||||||
Backbone = require('backbone');
|
|
||||||
} else {
|
|
||||||
Backbone = window.Backbone;
|
|
||||||
}
|
|
||||||
|
|
||||||
var GitEngine = require('../git').GitEngine;
|
var GitEngine = require('../git').GitEngine;
|
||||||
var AnimationFactory = require('../visuals/animation/animationFactory').AnimationFactory;
|
var AnimationFactory = require('../visuals/animation/animationFactory').AnimationFactory;
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
var _;
|
var _ = require('underscore');
|
||||||
var Backbone;
|
|
||||||
// horrible hack to get localStorage Backbone plugin
|
// horrible hack to get localStorage Backbone plugin
|
||||||
if (!require('../util').isBrowser()) {
|
var Backbone = (!require('../util').isBrowser()) ? Backbone = require('backbone') : Backbone = window.Backbone;
|
||||||
_ = require('underscore');
|
var Q = require('q');
|
||||||
Backbone = require('backbone');
|
|
||||||
} else {
|
|
||||||
Backbone = window.Backbone;
|
|
||||||
_ = window._;
|
|
||||||
}
|
|
||||||
|
|
||||||
var AnimationFactoryModule = require('../visuals/animation/animationFactory');
|
var AnimationFactoryModule = require('../visuals/animation/animationFactory');
|
||||||
var AnimationQueue = require('../visuals/animation').AnimationQueue;
|
var AnimationQueue = require('../visuals/animation').AnimationQueue;
|
||||||
|
@ -1018,23 +1012,33 @@ GitEngine.prototype.rebaseInteractive = function(targetSource, currentLocation)
|
||||||
// and actually launch the dialog
|
// and actually launch the dialog
|
||||||
this.animationQueue.set('defer', true);
|
this.animationQueue.set('defer', true);
|
||||||
|
|
||||||
var callback = _.bind(function(userSpecifiedRebase) {
|
var deferred = Q.defer();
|
||||||
|
deferred.promise
|
||||||
|
.then(_.bind(function(userSpecifiedRebase) {
|
||||||
// first, they might have dropped everything (annoying)
|
// first, they might have dropped everything (annoying)
|
||||||
if (!userSpecifiedRebase.length) {
|
if (!userSpecifiedRebase.length) {
|
||||||
this.command.setResult('Nothing to do...');
|
throw new GitError({
|
||||||
this.animationQueue.start();
|
msg: 'Nothing to do...'
|
||||||
return;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// finish the rebase crap and animate!
|
// finish the rebase crap and animate!
|
||||||
var animationData = this.rebaseFinish(userSpecifiedRebase, {}, targetSource, currentLocation);
|
var animationData = this.rebaseFinish(userSpecifiedRebase, {}, targetSource, currentLocation);
|
||||||
this.animationFactory.rebaseAnimation(this.animationQueue, animationData, this, this.gitVisuals);
|
this.animationFactory.rebaseAnimation(this.animationQueue, animationData, this, this.gitVisuals);
|
||||||
this.animationQueue.start();
|
this.animationQueue.start();
|
||||||
}, this);
|
|
||||||
|
}, this))
|
||||||
|
.fail(_.bind(function(err) {
|
||||||
|
this.filterError(err);
|
||||||
|
this.command.set('error', err);
|
||||||
|
this.animationQueue.start();
|
||||||
|
}, this))
|
||||||
|
.done();
|
||||||
|
|
||||||
var InteractiveRebaseView = require('../views/miscViews').InteractiveRebaseView;
|
var InteractiveRebaseView = require('../views/miscViews').InteractiveRebaseView;
|
||||||
|
// interactive rebase view will reject or resolve our promise
|
||||||
new InteractiveRebaseView({
|
new InteractiveRebaseView({
|
||||||
callback: callback,
|
deferred: deferred,
|
||||||
toRebase: toRebase,
|
toRebase: toRebase,
|
||||||
el: $('#dialogHolder')
|
el: $('#dialogHolder')
|
||||||
});
|
});
|
||||||
|
@ -1330,6 +1334,13 @@ GitEngine.prototype.unescapeQuotes = function(str) {
|
||||||
return str.replace(/'/g, "'");
|
return str.replace(/'/g, "'");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GitEngine.prototype.filterError = function(err) {
|
||||||
|
if (!(err instanceof GitError ||
|
||||||
|
err instanceof CommandResult)) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
GitEngine.prototype.dispatch = function(command, callback) {
|
GitEngine.prototype.dispatch = function(command, callback) {
|
||||||
// current command, options, and args are stored in the gitEngine
|
// current command, options, and args are stored in the gitEngine
|
||||||
// for easy reference during processing.
|
// for easy reference during processing.
|
||||||
|
@ -1351,15 +1362,11 @@ GitEngine.prototype.dispatch = function(command, callback) {
|
||||||
var methodName = command.get('method').replace(/-/g, '') + 'Starter';
|
var methodName = command.get('method').replace(/-/g, '') + 'Starter';
|
||||||
this[methodName]();
|
this[methodName]();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof GitError ||
|
this.filterError(err);
|
||||||
err instanceof CommandResult) {
|
|
||||||
// short circuit animation by just setting error and returning
|
// short circuit animation by just setting error and returning
|
||||||
command.set('error', err);
|
command.set('error', err);
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// only add the refresh if we didn't do manual animations
|
// only add the refresh if we didn't do manual animations
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
var _;
|
var _ = require('underscore');
|
||||||
var Backbone;
|
|
||||||
// horrible hack to get localStorage Backbone plugin
|
// horrible hack to get localStorage Backbone plugin
|
||||||
if (!require('../util').isBrowser()) {
|
var Backbone = (!require('../util').isBrowser()) ? Backbone = require('backbone') : Backbone = window.Backbone;
|
||||||
_ = require('underscore');
|
|
||||||
Backbone = require('backbone');
|
|
||||||
} else {
|
|
||||||
Backbone = window.Backbone;
|
|
||||||
_ = window._;
|
|
||||||
}
|
|
||||||
|
|
||||||
var Commit = require('../git').Commit;
|
var Commit = require('../git').Commit;
|
||||||
var Branch = require('../git').Branch;
|
var Branch = require('../git').Branch;
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
var _;
|
var _ = require('underscore');
|
||||||
var Backbone;
|
|
||||||
// horrible hack to get localStorage Backbone plugin
|
// horrible hack to get localStorage Backbone plugin
|
||||||
if (!require('../util').isBrowser()) {
|
var Backbone = (!require('../util').isBrowser()) ? Backbone = require('backbone') : Backbone = window.Backbone;
|
||||||
_ = require('underscore');
|
|
||||||
Backbone = require('backbone');
|
|
||||||
} else {
|
|
||||||
Backbone = window.Backbone;
|
|
||||||
_ = window._;
|
|
||||||
}
|
|
||||||
|
|
||||||
var Errors = require('../util/errors');
|
var Errors = require('../util/errors');
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
var _;
|
var _ = require('underscore');
|
||||||
var Backbone;
|
|
||||||
// horrible hack to get localStorage Backbone plugin
|
// horrible hack to get localStorage Backbone plugin
|
||||||
if (!require('../util').isBrowser()) {
|
var Backbone = (!require('../util').isBrowser()) ? Backbone = require('backbone') : Backbone = window.Backbone;
|
||||||
_ = require('underscore');
|
|
||||||
Backbone = require('backbone');
|
|
||||||
} else {
|
|
||||||
Backbone = window.Backbone;
|
|
||||||
_ = window._;
|
|
||||||
}
|
|
||||||
|
|
||||||
var MyError = Backbone.Model.extend({
|
var MyError = Backbone.Model.extend({
|
||||||
defaults: {
|
defaults: {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
var GitError = require('../util/errors').GitError;
|
||||||
|
|
||||||
var InteractiveRebaseView = Backbone.View.extend({
|
var InteractiveRebaseView = Backbone.View.extend({
|
||||||
tagName: 'div',
|
tagName: 'div',
|
||||||
template: _.template($('#interactive-rebase-template').html()),
|
template: _.template($('#interactive-rebase-template').html()),
|
||||||
|
@ -8,7 +10,7 @@ var InteractiveRebaseView = Backbone.View.extend({
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
this.hasClicked = false;
|
this.hasClicked = false;
|
||||||
this.rebaseCallback = options.callback;
|
this.deferred = options.deferred;
|
||||||
|
|
||||||
this.rebaseArray = options.toRebase;
|
this.rebaseArray = options.toRebase;
|
||||||
|
|
||||||
|
@ -71,10 +73,9 @@ var InteractiveRebaseView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
this.rebaseCallback(toRebase);
|
this.deferred.resolve(toRebase);
|
||||||
|
|
||||||
this.$el.html('');
|
|
||||||
// garbage collection will get us
|
// garbage collection will get us
|
||||||
|
this.$el.html('');
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
var _;
|
var _ = require('underscore');
|
||||||
var Backbone;
|
|
||||||
// horrible hack to get localStorage Backbone plugin
|
// horrible hack to get localStorage Backbone plugin
|
||||||
if (!require('../../util').isBrowser()) {
|
var Backbone = (!require('../../util').isBrowser()) ? Backbone = require('backbone') : Backbone = window.Backbone;
|
||||||
_ = require('underscore');
|
|
||||||
Backbone = require('backbone');
|
|
||||||
} else {
|
|
||||||
Backbone = window.Backbone;
|
|
||||||
_ = window._;
|
|
||||||
}
|
|
||||||
|
|
||||||
var Animation = require('./index').Animation;
|
var Animation = require('./index').Animation;
|
||||||
var GRAPHICS = require('../../util/constants').GRAPHICS;
|
var GRAPHICS = require('../../util/constants').GRAPHICS;
|
||||||
|
|
|
@ -1,15 +1,7 @@
|
||||||
var GLOBAL = require('../../util/constants').GLOBAL;
|
var _ = require('underscore');
|
||||||
|
|
||||||
var _;
|
|
||||||
var Backbone;
|
|
||||||
// horrible hack to get localStorage Backbone plugin
|
// horrible hack to get localStorage Backbone plugin
|
||||||
if (!require('../../util').isBrowser()) {
|
var Backbone = (!require('../../util').isBrowser()) ? Backbone = require('backbone') : Backbone = window.Backbone;
|
||||||
_ = require('underscore');
|
var GLOBAL = require('../../util/constants').GLOBAL;
|
||||||
Backbone = require('backbone');
|
|
||||||
} else {
|
|
||||||
Backbone = window.Backbone;
|
|
||||||
_ = window._;
|
|
||||||
}
|
|
||||||
|
|
||||||
var Animation = Backbone.Model.extend({
|
var Animation = Backbone.Model.extend({
|
||||||
defaults: {
|
defaults: {
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
|
|
||||||
var Backbone;
|
|
||||||
// horrible hack to get localStorage Backbone plugin
|
// horrible hack to get localStorage Backbone plugin
|
||||||
if (!require('../util').isBrowser()) {
|
var Backbone = (!require('../util').isBrowser()) ? Backbone = require('backbone') : Backbone = window.Backbone;
|
||||||
Backbone = require('backbone');
|
|
||||||
} else {
|
|
||||||
Backbone = window.Backbone;
|
|
||||||
}
|
|
||||||
|
|
||||||
var GRAPHICS = require('../util/constants').GRAPHICS;
|
var GRAPHICS = require('../util/constants').GRAPHICS;
|
||||||
var GLOBAL = require('../util/constants').GLOBAL;
|
var GLOBAL = require('../util/constants').GLOBAL;
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
var _;
|
var _ = require('underscore');
|
||||||
var Backbone;
|
|
||||||
// horrible hack to get localStorage Backbone plugin
|
// horrible hack to get localStorage Backbone plugin
|
||||||
if (!require('../util').isBrowser()) {
|
var Backbone = (!require('../util').isBrowser()) ? Backbone = require('backbone') : Backbone = window.Backbone;
|
||||||
_ = require('underscore');
|
|
||||||
Backbone = require('backbone');
|
|
||||||
} else {
|
|
||||||
Backbone = window.Backbone;
|
|
||||||
_ = window._;
|
|
||||||
}
|
|
||||||
|
|
||||||
var GRAPHICS = require('../util/constants').GRAPHICS;
|
var GRAPHICS = require('../util/constants').GRAPHICS;
|
||||||
|
|
||||||
|
|
3
todo.txt
3
todo.txt
|
@ -13,7 +13,6 @@ Medium things:
|
||||||
|
|
||||||
Small things to implement:
|
Small things to implement:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
[ ] remove underscore in browser
|
|
||||||
|
|
||||||
Minor Bugs to fix:
|
Minor Bugs to fix:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -36,4 +35,6 @@ Done things:
|
||||||
[x] Great git test coverage
|
[x] Great git test coverage
|
||||||
[x] gitEngine loads from tree immediately, not the weird thing we have now!
|
[x] gitEngine loads from tree immediately, not the weird thing we have now!
|
||||||
[x] nice opacity fade in
|
[x] nice opacity fade in
|
||||||
|
[x] clean up require
|
||||||
|
[x] promise based callback for interactive rebase WITH FAIL awesome
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue