mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-25 23:48:34 +02:00
working on headless, some tests fail because promise does not resolve or execute
This commit is contained in:
parent
d0e206bcc4
commit
89377b2956
4 changed files with 105 additions and 59 deletions
114
build/bundle.js
114
build/bundle.js
|
@ -7082,8 +7082,9 @@ function GitEngine(options) {
|
||||||
this.eventBaton.stealBaton('processGitCommand', this.dispatch, this);
|
this.eventBaton.stealBaton('processGitCommand', this.dispatch, this);
|
||||||
|
|
||||||
// poor man's dependency injection
|
// poor man's dependency injection
|
||||||
this.animationFactory = options.animationFactory ||
|
if (options.animationFactory) {
|
||||||
AnimationFactory;
|
AnimationFactory = options.animationFactory;
|
||||||
|
}
|
||||||
|
|
||||||
// global variable to keep track of the options given
|
// global variable to keep track of the options given
|
||||||
// along with the command call.
|
// along with the command call.
|
||||||
|
@ -7314,7 +7315,7 @@ GitEngine.prototype.makeOrigin = function(treeString) {
|
||||||
// and then here is the crazy part -- we need the ORIGIN to refresh
|
// and then here is the crazy part -- we need the ORIGIN to refresh
|
||||||
// itself in a separate animation. @_____@
|
// itself in a separate animation. @_____@
|
||||||
this.origin.externalRefresh();
|
this.origin.externalRefresh();
|
||||||
this.animationFactory.playRefreshAnimationAndFinish(this.gitVisuals, this.animationQueue);
|
AnimationFactory.playRefreshAnimationAndFinish(this.gitVisuals, this.animationQueue);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
// TODO handle the case where the master target on origin is not present
|
// TODO handle the case where the master target on origin is not present
|
||||||
|
@ -7661,7 +7662,7 @@ GitEngine.prototype.revert = function(whichCommits) {
|
||||||
var chain = deferred.promise;
|
var chain = deferred.promise;
|
||||||
var destBranch = this.resolveID('HEAD');
|
var destBranch = this.resolveID('HEAD');
|
||||||
|
|
||||||
chain = this.animationFactory.highlightEachWithPromise(
|
chain = AnimationFactory.highlightEachWithPromise(
|
||||||
chain,
|
chain,
|
||||||
toRevert,
|
toRevert,
|
||||||
destBranch
|
destBranch
|
||||||
|
@ -7680,7 +7681,7 @@ GitEngine.prototype.revert = function(whichCommits) {
|
||||||
});
|
});
|
||||||
base = newCommit;
|
base = newCommit;
|
||||||
|
|
||||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||||
newCommit,
|
newCommit,
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
);
|
);
|
||||||
|
@ -7696,7 +7697,7 @@ GitEngine.prototype.revert = function(whichCommits) {
|
||||||
// done! update our location
|
// done! update our location
|
||||||
chain = chain.then(_.bind(function() {
|
chain = chain.then(_.bind(function() {
|
||||||
this.setTargetLocation('HEAD', base);
|
this.setTargetLocation('HEAD', base);
|
||||||
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
|
return AnimationFactory.playRefreshAnimation(this.gitVisuals);
|
||||||
}, this));
|
}, this));
|
||||||
|
|
||||||
this.animationQueue.thenFinish(chain, deferred);
|
this.animationQueue.thenFinish(chain, deferred);
|
||||||
|
@ -7755,7 +7756,7 @@ GitEngine.prototype.cherrypickStarter = function() {
|
||||||
var chain = deferred.promise;
|
var chain = deferred.promise;
|
||||||
var destinationBranch = this.resolveID('HEAD');
|
var destinationBranch = this.resolveID('HEAD');
|
||||||
|
|
||||||
chain = this.animationFactory.highlightEachWithPromise(
|
chain = AnimationFactory.highlightEachWithPromise(
|
||||||
chain,
|
chain,
|
||||||
toCherrypick,
|
toCherrypick,
|
||||||
destinationBranch
|
destinationBranch
|
||||||
|
@ -7763,7 +7764,7 @@ GitEngine.prototype.cherrypickStarter = function() {
|
||||||
|
|
||||||
var chainStep = _.bind(function(commit) {
|
var chainStep = _.bind(function(commit) {
|
||||||
var newCommit = this.cherrypick(commit);
|
var newCommit = this.cherrypick(commit);
|
||||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||||
newCommit,
|
newCommit,
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
);
|
);
|
||||||
|
@ -7830,7 +7831,7 @@ GitEngine.prototype.fetch = function() {
|
||||||
commitsToAnimate.sort(_.bind(this.idSortFunc, this));
|
commitsToAnimate.sort(_.bind(this.idSortFunc, this));
|
||||||
|
|
||||||
_.each(commitsToAnimate, function(newCommit) {
|
_.each(commitsToAnimate, function(newCommit) {
|
||||||
this.animationFactory.genCommitBirthAnimation(
|
AnimationFactory.genCommitBirthAnimation(
|
||||||
this.animationQueue,
|
this.animationQueue,
|
||||||
newCommit,
|
newCommit,
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
|
@ -7840,7 +7841,7 @@ GitEngine.prototype.fetch = function() {
|
||||||
var originLocation = this.origin.exportTree().branches.master.target;
|
var originLocation = this.origin.exportTree().branches.master.target;
|
||||||
// yay! now we just set o/master and do a simple refresh
|
// yay! now we just set o/master and do a simple refresh
|
||||||
this.setTargetLocation(this.refs['o/master'], this.refs[originLocation]);
|
this.setTargetLocation(this.refs['o/master'], this.refs[originLocation]);
|
||||||
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
AnimationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.pullStarter = function() {
|
GitEngine.prototype.pullStarter = function() {
|
||||||
|
@ -7886,7 +7887,7 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
|
||||||
|
|
||||||
var chainStep = _.bind(function() {
|
var chainStep = _.bind(function() {
|
||||||
var newCommit = makeOriginCommit();
|
var newCommit = makeOriginCommit();
|
||||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||||
newCommit,
|
newCommit,
|
||||||
this.origin.gitVisuals
|
this.origin.gitVisuals
|
||||||
);
|
);
|
||||||
|
@ -7959,7 +7960,7 @@ GitEngine.prototype.commitStarter = function() {
|
||||||
newCommit.set('commitMessage', msg);
|
newCommit.set('commitMessage', msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
var promise = this.animationFactory.playCommitBirthPromiseAnimation(
|
var promise = AnimationFactory.playCommitBirthPromiseAnimation(
|
||||||
newCommit,
|
newCommit,
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
);
|
);
|
||||||
|
@ -8467,7 +8468,7 @@ GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
chain = this.animationFactory.highlightEachWithPromise(
|
chain = AnimationFactory.highlightEachWithPromise(
|
||||||
chain,
|
chain,
|
||||||
toRebase,
|
toRebase,
|
||||||
destinationBranch
|
destinationBranch
|
||||||
|
@ -8481,7 +8482,7 @@ GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource
|
||||||
var newCommit = this.makeCommit([base], newId);
|
var newCommit = this.makeCommit([base], newId);
|
||||||
base = newCommit;
|
base = newCommit;
|
||||||
|
|
||||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||||
newCommit,
|
newCommit,
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
);
|
);
|
||||||
|
@ -8504,7 +8505,7 @@ GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource
|
||||||
this.setTargetLocation(currentLocation, base);
|
this.setTargetLocation(currentLocation, base);
|
||||||
this.checkout(currentLocation);
|
this.checkout(currentLocation);
|
||||||
}
|
}
|
||||||
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
|
return AnimationFactory.playRefreshAnimation(this.gitVisuals);
|
||||||
}, this));
|
}, this));
|
||||||
|
|
||||||
this.animationQueue.thenFinish(chain, deferred);
|
this.animationQueue.thenFinish(chain, deferred);
|
||||||
|
@ -8517,11 +8518,11 @@ GitEngine.prototype.mergeStarter = function() {
|
||||||
|
|
||||||
if (newCommit === undefined) {
|
if (newCommit === undefined) {
|
||||||
// its just a fast forwrard
|
// its just a fast forwrard
|
||||||
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
AnimationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.animationFactory.genCommitBirthAnimation(this.animationQueue, newCommit, this.gitVisuals);
|
AnimationFactory.genCommitBirthAnimation(this.animationQueue, newCommit, this.gitVisuals);
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.merge = function(targetSource) {
|
GitEngine.prototype.merge = function(targetSource) {
|
||||||
|
@ -8761,7 +8762,7 @@ GitEngine.prototype.externalRefresh = function() {
|
||||||
this.animationQueue = new AnimationQueue({
|
this.animationQueue = new AnimationQueue({
|
||||||
callback: function() {}
|
callback: function() {}
|
||||||
});
|
});
|
||||||
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
AnimationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||||
this.animationQueue.start();
|
this.animationQueue.start();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8796,7 +8797,7 @@ GitEngine.prototype.dispatch = function(command, deferred) {
|
||||||
|
|
||||||
// only add the refresh if we didn't do manual animations
|
// only add the refresh if we didn't do manual animations
|
||||||
if (!this.animationQueue.get('animations').length && !willStartAuto) {
|
if (!this.animationQueue.get('animations').length && !willStartAuto) {
|
||||||
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
AnimationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||||
}
|
}
|
||||||
|
|
||||||
// animation queue will call the callback when its done
|
// animation queue will call the callback when its done
|
||||||
|
@ -21894,6 +21895,22 @@ var Command = require('../models/commandModel').Command;
|
||||||
var mock = require('../util/mock').mock;
|
var mock = require('../util/mock').mock;
|
||||||
var util = require('../util');
|
var util = require('../util');
|
||||||
|
|
||||||
|
function getMockFactory() {
|
||||||
|
var mockFactory = {};
|
||||||
|
for (var key in AnimationFactory) {
|
||||||
|
mockFactory[key] = function() {
|
||||||
|
return Q.defer().promise;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// special method that does stuff
|
||||||
|
mockFactory.playRefreshAnimationAndFinish = function(gitVisuals, aQueue) {
|
||||||
|
console.log('trying to finish');
|
||||||
|
aQueue.thenFinish(Q.defer().promise);
|
||||||
|
};
|
||||||
|
|
||||||
|
return mockFactory;
|
||||||
|
}
|
||||||
|
|
||||||
var HeadlessGit = function() {
|
var HeadlessGit = function() {
|
||||||
this.init();
|
this.init();
|
||||||
};
|
};
|
||||||
|
@ -21905,7 +21922,7 @@ HeadlessGit.prototype.init = function() {
|
||||||
|
|
||||||
// here we mock visuals and animation factory so the git engine
|
// here we mock visuals and animation factory so the git engine
|
||||||
// is headless
|
// is headless
|
||||||
var animationFactory = mock(AnimationFactory);
|
var animationFactory = getMockFactory();
|
||||||
var gitVisuals = mock(GitVisuals);
|
var gitVisuals = mock(GitVisuals);
|
||||||
|
|
||||||
this.gitEngine = new GitEngine({
|
this.gitEngine = new GitEngine({
|
||||||
|
@ -22808,6 +22825,22 @@ var Command = require('../models/commandModel').Command;
|
||||||
var mock = require('../util/mock').mock;
|
var mock = require('../util/mock').mock;
|
||||||
var util = require('../util');
|
var util = require('../util');
|
||||||
|
|
||||||
|
function getMockFactory() {
|
||||||
|
var mockFactory = {};
|
||||||
|
for (var key in AnimationFactory) {
|
||||||
|
mockFactory[key] = function() {
|
||||||
|
return Q.defer().promise;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// special method that does stuff
|
||||||
|
mockFactory.playRefreshAnimationAndFinish = function(gitVisuals, aQueue) {
|
||||||
|
console.log('trying to finish');
|
||||||
|
aQueue.thenFinish(Q.defer().promise);
|
||||||
|
};
|
||||||
|
|
||||||
|
return mockFactory;
|
||||||
|
}
|
||||||
|
|
||||||
var HeadlessGit = function() {
|
var HeadlessGit = function() {
|
||||||
this.init();
|
this.init();
|
||||||
};
|
};
|
||||||
|
@ -22819,7 +22852,7 @@ HeadlessGit.prototype.init = function() {
|
||||||
|
|
||||||
// here we mock visuals and animation factory so the git engine
|
// here we mock visuals and animation factory so the git engine
|
||||||
// is headless
|
// is headless
|
||||||
var animationFactory = mock(AnimationFactory);
|
var animationFactory = getMockFactory();
|
||||||
var gitVisuals = mock(GitVisuals);
|
var gitVisuals = mock(GitVisuals);
|
||||||
|
|
||||||
this.gitEngine = new GitEngine({
|
this.gitEngine = new GitEngine({
|
||||||
|
@ -22878,8 +22911,9 @@ function GitEngine(options) {
|
||||||
this.eventBaton.stealBaton('processGitCommand', this.dispatch, this);
|
this.eventBaton.stealBaton('processGitCommand', this.dispatch, this);
|
||||||
|
|
||||||
// poor man's dependency injection
|
// poor man's dependency injection
|
||||||
this.animationFactory = options.animationFactory ||
|
if (options.animationFactory) {
|
||||||
AnimationFactory;
|
AnimationFactory = options.animationFactory;
|
||||||
|
}
|
||||||
|
|
||||||
// global variable to keep track of the options given
|
// global variable to keep track of the options given
|
||||||
// along with the command call.
|
// along with the command call.
|
||||||
|
@ -23110,7 +23144,7 @@ GitEngine.prototype.makeOrigin = function(treeString) {
|
||||||
// and then here is the crazy part -- we need the ORIGIN to refresh
|
// and then here is the crazy part -- we need the ORIGIN to refresh
|
||||||
// itself in a separate animation. @_____@
|
// itself in a separate animation. @_____@
|
||||||
this.origin.externalRefresh();
|
this.origin.externalRefresh();
|
||||||
this.animationFactory.playRefreshAnimationAndFinish(this.gitVisuals, this.animationQueue);
|
AnimationFactory.playRefreshAnimationAndFinish(this.gitVisuals, this.animationQueue);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
// TODO handle the case where the master target on origin is not present
|
// TODO handle the case where the master target on origin is not present
|
||||||
|
@ -23457,7 +23491,7 @@ GitEngine.prototype.revert = function(whichCommits) {
|
||||||
var chain = deferred.promise;
|
var chain = deferred.promise;
|
||||||
var destBranch = this.resolveID('HEAD');
|
var destBranch = this.resolveID('HEAD');
|
||||||
|
|
||||||
chain = this.animationFactory.highlightEachWithPromise(
|
chain = AnimationFactory.highlightEachWithPromise(
|
||||||
chain,
|
chain,
|
||||||
toRevert,
|
toRevert,
|
||||||
destBranch
|
destBranch
|
||||||
|
@ -23476,7 +23510,7 @@ GitEngine.prototype.revert = function(whichCommits) {
|
||||||
});
|
});
|
||||||
base = newCommit;
|
base = newCommit;
|
||||||
|
|
||||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||||
newCommit,
|
newCommit,
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
);
|
);
|
||||||
|
@ -23492,7 +23526,7 @@ GitEngine.prototype.revert = function(whichCommits) {
|
||||||
// done! update our location
|
// done! update our location
|
||||||
chain = chain.then(_.bind(function() {
|
chain = chain.then(_.bind(function() {
|
||||||
this.setTargetLocation('HEAD', base);
|
this.setTargetLocation('HEAD', base);
|
||||||
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
|
return AnimationFactory.playRefreshAnimation(this.gitVisuals);
|
||||||
}, this));
|
}, this));
|
||||||
|
|
||||||
this.animationQueue.thenFinish(chain, deferred);
|
this.animationQueue.thenFinish(chain, deferred);
|
||||||
|
@ -23551,7 +23585,7 @@ GitEngine.prototype.cherrypickStarter = function() {
|
||||||
var chain = deferred.promise;
|
var chain = deferred.promise;
|
||||||
var destinationBranch = this.resolveID('HEAD');
|
var destinationBranch = this.resolveID('HEAD');
|
||||||
|
|
||||||
chain = this.animationFactory.highlightEachWithPromise(
|
chain = AnimationFactory.highlightEachWithPromise(
|
||||||
chain,
|
chain,
|
||||||
toCherrypick,
|
toCherrypick,
|
||||||
destinationBranch
|
destinationBranch
|
||||||
|
@ -23559,7 +23593,7 @@ GitEngine.prototype.cherrypickStarter = function() {
|
||||||
|
|
||||||
var chainStep = _.bind(function(commit) {
|
var chainStep = _.bind(function(commit) {
|
||||||
var newCommit = this.cherrypick(commit);
|
var newCommit = this.cherrypick(commit);
|
||||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||||
newCommit,
|
newCommit,
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
);
|
);
|
||||||
|
@ -23626,7 +23660,7 @@ GitEngine.prototype.fetch = function() {
|
||||||
commitsToAnimate.sort(_.bind(this.idSortFunc, this));
|
commitsToAnimate.sort(_.bind(this.idSortFunc, this));
|
||||||
|
|
||||||
_.each(commitsToAnimate, function(newCommit) {
|
_.each(commitsToAnimate, function(newCommit) {
|
||||||
this.animationFactory.genCommitBirthAnimation(
|
AnimationFactory.genCommitBirthAnimation(
|
||||||
this.animationQueue,
|
this.animationQueue,
|
||||||
newCommit,
|
newCommit,
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
|
@ -23636,7 +23670,7 @@ GitEngine.prototype.fetch = function() {
|
||||||
var originLocation = this.origin.exportTree().branches.master.target;
|
var originLocation = this.origin.exportTree().branches.master.target;
|
||||||
// yay! now we just set o/master and do a simple refresh
|
// yay! now we just set o/master and do a simple refresh
|
||||||
this.setTargetLocation(this.refs['o/master'], this.refs[originLocation]);
|
this.setTargetLocation(this.refs['o/master'], this.refs[originLocation]);
|
||||||
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
AnimationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.pullStarter = function() {
|
GitEngine.prototype.pullStarter = function() {
|
||||||
|
@ -23682,7 +23716,7 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
|
||||||
|
|
||||||
var chainStep = _.bind(function() {
|
var chainStep = _.bind(function() {
|
||||||
var newCommit = makeOriginCommit();
|
var newCommit = makeOriginCommit();
|
||||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||||
newCommit,
|
newCommit,
|
||||||
this.origin.gitVisuals
|
this.origin.gitVisuals
|
||||||
);
|
);
|
||||||
|
@ -23755,7 +23789,7 @@ GitEngine.prototype.commitStarter = function() {
|
||||||
newCommit.set('commitMessage', msg);
|
newCommit.set('commitMessage', msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
var promise = this.animationFactory.playCommitBirthPromiseAnimation(
|
var promise = AnimationFactory.playCommitBirthPromiseAnimation(
|
||||||
newCommit,
|
newCommit,
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
);
|
);
|
||||||
|
@ -24263,7 +24297,7 @@ GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
chain = this.animationFactory.highlightEachWithPromise(
|
chain = AnimationFactory.highlightEachWithPromise(
|
||||||
chain,
|
chain,
|
||||||
toRebase,
|
toRebase,
|
||||||
destinationBranch
|
destinationBranch
|
||||||
|
@ -24277,7 +24311,7 @@ GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource
|
||||||
var newCommit = this.makeCommit([base], newId);
|
var newCommit = this.makeCommit([base], newId);
|
||||||
base = newCommit;
|
base = newCommit;
|
||||||
|
|
||||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||||
newCommit,
|
newCommit,
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
);
|
);
|
||||||
|
@ -24300,7 +24334,7 @@ GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource
|
||||||
this.setTargetLocation(currentLocation, base);
|
this.setTargetLocation(currentLocation, base);
|
||||||
this.checkout(currentLocation);
|
this.checkout(currentLocation);
|
||||||
}
|
}
|
||||||
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
|
return AnimationFactory.playRefreshAnimation(this.gitVisuals);
|
||||||
}, this));
|
}, this));
|
||||||
|
|
||||||
this.animationQueue.thenFinish(chain, deferred);
|
this.animationQueue.thenFinish(chain, deferred);
|
||||||
|
@ -24313,11 +24347,11 @@ GitEngine.prototype.mergeStarter = function() {
|
||||||
|
|
||||||
if (newCommit === undefined) {
|
if (newCommit === undefined) {
|
||||||
// its just a fast forwrard
|
// its just a fast forwrard
|
||||||
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
AnimationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.animationFactory.genCommitBirthAnimation(this.animationQueue, newCommit, this.gitVisuals);
|
AnimationFactory.genCommitBirthAnimation(this.animationQueue, newCommit, this.gitVisuals);
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.merge = function(targetSource) {
|
GitEngine.prototype.merge = function(targetSource) {
|
||||||
|
@ -24557,7 +24591,7 @@ GitEngine.prototype.externalRefresh = function() {
|
||||||
this.animationQueue = new AnimationQueue({
|
this.animationQueue = new AnimationQueue({
|
||||||
callback: function() {}
|
callback: function() {}
|
||||||
});
|
});
|
||||||
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
AnimationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||||
this.animationQueue.start();
|
this.animationQueue.start();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24592,7 +24626,7 @@ GitEngine.prototype.dispatch = function(command, deferred) {
|
||||||
|
|
||||||
// only add the refresh if we didn't do manual animations
|
// only add the refresh if we didn't do manual animations
|
||||||
if (!this.animationQueue.get('animations').length && !willStartAuto) {
|
if (!this.animationQueue.get('animations').length && !willStartAuto) {
|
||||||
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
AnimationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||||
}
|
}
|
||||||
|
|
||||||
// animation queue will call the callback when its done
|
// animation queue will call the callback when its done
|
||||||
|
|
|
@ -11,6 +11,11 @@ var compareAnswer = function(headless, expectedJSON) {
|
||||||
var actualTree = headless.gitEngine.exportTree();
|
var actualTree = headless.gitEngine.exportTree();
|
||||||
|
|
||||||
var equal = treeCompare.compareTrees(expectedTree, actualTree);
|
var equal = treeCompare.compareTrees(expectedTree, actualTree);
|
||||||
|
if (!equal) {
|
||||||
|
console.log('tree1', expectedTree);
|
||||||
|
console.log('tree2', actualTree);
|
||||||
|
console.log('~~~~~~~~~~~~~~~~~~~~~');
|
||||||
|
}
|
||||||
expect(equal).toBe(true);
|
expect(equal).toBe(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,12 @@ function getMockFactory() {
|
||||||
return Q.defer().promise;
|
return Q.defer().promise;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
// special method that does stuff
|
||||||
|
mockFactory.playRefreshAnimationAndFinish = function(gitVisuals, aQueue) {
|
||||||
|
console.log('trying to finish');
|
||||||
|
aQueue.thenFinish(Q.defer().promise);
|
||||||
|
};
|
||||||
|
|
||||||
return mockFactory;
|
return mockFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,9 @@ function GitEngine(options) {
|
||||||
this.eventBaton.stealBaton('processGitCommand', this.dispatch, this);
|
this.eventBaton.stealBaton('processGitCommand', this.dispatch, this);
|
||||||
|
|
||||||
// poor man's dependency injection
|
// poor man's dependency injection
|
||||||
this.animationFactory = options.animationFactory ||
|
if (options.animationFactory) {
|
||||||
AnimationFactory;
|
AnimationFactory = options.animationFactory;
|
||||||
|
}
|
||||||
|
|
||||||
// global variable to keep track of the options given
|
// global variable to keep track of the options given
|
||||||
// along with the command call.
|
// along with the command call.
|
||||||
|
@ -261,7 +262,7 @@ GitEngine.prototype.makeOrigin = function(treeString) {
|
||||||
// and then here is the crazy part -- we need the ORIGIN to refresh
|
// and then here is the crazy part -- we need the ORIGIN to refresh
|
||||||
// itself in a separate animation. @_____@
|
// itself in a separate animation. @_____@
|
||||||
this.origin.externalRefresh();
|
this.origin.externalRefresh();
|
||||||
this.animationFactory.playRefreshAnimationAndFinish(this.gitVisuals, this.animationQueue);
|
AnimationFactory.playRefreshAnimationAndFinish(this.gitVisuals, this.animationQueue);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
// TODO handle the case where the master target on origin is not present
|
// TODO handle the case where the master target on origin is not present
|
||||||
|
@ -608,7 +609,7 @@ GitEngine.prototype.revert = function(whichCommits) {
|
||||||
var chain = deferred.promise;
|
var chain = deferred.promise;
|
||||||
var destBranch = this.resolveID('HEAD');
|
var destBranch = this.resolveID('HEAD');
|
||||||
|
|
||||||
chain = this.animationFactory.highlightEachWithPromise(
|
chain = AnimationFactory.highlightEachWithPromise(
|
||||||
chain,
|
chain,
|
||||||
toRevert,
|
toRevert,
|
||||||
destBranch
|
destBranch
|
||||||
|
@ -627,7 +628,7 @@ GitEngine.prototype.revert = function(whichCommits) {
|
||||||
});
|
});
|
||||||
base = newCommit;
|
base = newCommit;
|
||||||
|
|
||||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||||
newCommit,
|
newCommit,
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
);
|
);
|
||||||
|
@ -643,7 +644,7 @@ GitEngine.prototype.revert = function(whichCommits) {
|
||||||
// done! update our location
|
// done! update our location
|
||||||
chain = chain.then(_.bind(function() {
|
chain = chain.then(_.bind(function() {
|
||||||
this.setTargetLocation('HEAD', base);
|
this.setTargetLocation('HEAD', base);
|
||||||
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
|
return AnimationFactory.playRefreshAnimation(this.gitVisuals);
|
||||||
}, this));
|
}, this));
|
||||||
|
|
||||||
this.animationQueue.thenFinish(chain, deferred);
|
this.animationQueue.thenFinish(chain, deferred);
|
||||||
|
@ -702,7 +703,7 @@ GitEngine.prototype.cherrypickStarter = function() {
|
||||||
var chain = deferred.promise;
|
var chain = deferred.promise;
|
||||||
var destinationBranch = this.resolveID('HEAD');
|
var destinationBranch = this.resolveID('HEAD');
|
||||||
|
|
||||||
chain = this.animationFactory.highlightEachWithPromise(
|
chain = AnimationFactory.highlightEachWithPromise(
|
||||||
chain,
|
chain,
|
||||||
toCherrypick,
|
toCherrypick,
|
||||||
destinationBranch
|
destinationBranch
|
||||||
|
@ -710,7 +711,7 @@ GitEngine.prototype.cherrypickStarter = function() {
|
||||||
|
|
||||||
var chainStep = _.bind(function(commit) {
|
var chainStep = _.bind(function(commit) {
|
||||||
var newCommit = this.cherrypick(commit);
|
var newCommit = this.cherrypick(commit);
|
||||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||||
newCommit,
|
newCommit,
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
);
|
);
|
||||||
|
@ -777,7 +778,7 @@ GitEngine.prototype.fetch = function() {
|
||||||
commitsToAnimate.sort(_.bind(this.idSortFunc, this));
|
commitsToAnimate.sort(_.bind(this.idSortFunc, this));
|
||||||
|
|
||||||
_.each(commitsToAnimate, function(newCommit) {
|
_.each(commitsToAnimate, function(newCommit) {
|
||||||
this.animationFactory.genCommitBirthAnimation(
|
AnimationFactory.genCommitBirthAnimation(
|
||||||
this.animationQueue,
|
this.animationQueue,
|
||||||
newCommit,
|
newCommit,
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
|
@ -787,7 +788,7 @@ GitEngine.prototype.fetch = function() {
|
||||||
var originLocation = this.origin.exportTree().branches.master.target;
|
var originLocation = this.origin.exportTree().branches.master.target;
|
||||||
// yay! now we just set o/master and do a simple refresh
|
// yay! now we just set o/master and do a simple refresh
|
||||||
this.setTargetLocation(this.refs['o/master'], this.refs[originLocation]);
|
this.setTargetLocation(this.refs['o/master'], this.refs[originLocation]);
|
||||||
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
AnimationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.pullStarter = function() {
|
GitEngine.prototype.pullStarter = function() {
|
||||||
|
@ -833,7 +834,7 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
|
||||||
|
|
||||||
var chainStep = _.bind(function() {
|
var chainStep = _.bind(function() {
|
||||||
var newCommit = makeOriginCommit();
|
var newCommit = makeOriginCommit();
|
||||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||||
newCommit,
|
newCommit,
|
||||||
this.origin.gitVisuals
|
this.origin.gitVisuals
|
||||||
);
|
);
|
||||||
|
@ -906,7 +907,7 @@ GitEngine.prototype.commitStarter = function() {
|
||||||
newCommit.set('commitMessage', msg);
|
newCommit.set('commitMessage', msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
var promise = this.animationFactory.playCommitBirthPromiseAnimation(
|
var promise = AnimationFactory.playCommitBirthPromiseAnimation(
|
||||||
newCommit,
|
newCommit,
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
);
|
);
|
||||||
|
@ -1414,7 +1415,7 @@ GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
chain = this.animationFactory.highlightEachWithPromise(
|
chain = AnimationFactory.highlightEachWithPromise(
|
||||||
chain,
|
chain,
|
||||||
toRebase,
|
toRebase,
|
||||||
destinationBranch
|
destinationBranch
|
||||||
|
@ -1428,7 +1429,7 @@ GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource
|
||||||
var newCommit = this.makeCommit([base], newId);
|
var newCommit = this.makeCommit([base], newId);
|
||||||
base = newCommit;
|
base = newCommit;
|
||||||
|
|
||||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||||
newCommit,
|
newCommit,
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
);
|
);
|
||||||
|
@ -1451,7 +1452,7 @@ GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource
|
||||||
this.setTargetLocation(currentLocation, base);
|
this.setTargetLocation(currentLocation, base);
|
||||||
this.checkout(currentLocation);
|
this.checkout(currentLocation);
|
||||||
}
|
}
|
||||||
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
|
return AnimationFactory.playRefreshAnimation(this.gitVisuals);
|
||||||
}, this));
|
}, this));
|
||||||
|
|
||||||
this.animationQueue.thenFinish(chain, deferred);
|
this.animationQueue.thenFinish(chain, deferred);
|
||||||
|
@ -1464,11 +1465,11 @@ GitEngine.prototype.mergeStarter = function() {
|
||||||
|
|
||||||
if (newCommit === undefined) {
|
if (newCommit === undefined) {
|
||||||
// its just a fast forwrard
|
// its just a fast forwrard
|
||||||
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
AnimationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.animationFactory.genCommitBirthAnimation(this.animationQueue, newCommit, this.gitVisuals);
|
AnimationFactory.genCommitBirthAnimation(this.animationQueue, newCommit, this.gitVisuals);
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.merge = function(targetSource) {
|
GitEngine.prototype.merge = function(targetSource) {
|
||||||
|
@ -1708,7 +1709,7 @@ GitEngine.prototype.externalRefresh = function() {
|
||||||
this.animationQueue = new AnimationQueue({
|
this.animationQueue = new AnimationQueue({
|
||||||
callback: function() {}
|
callback: function() {}
|
||||||
});
|
});
|
||||||
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
AnimationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||||
this.animationQueue.start();
|
this.animationQueue.start();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1743,7 +1744,7 @@ GitEngine.prototype.dispatch = function(command, deferred) {
|
||||||
|
|
||||||
// only add the refresh if we didn't do manual animations
|
// only add the refresh if we didn't do manual animations
|
||||||
if (!this.animationQueue.get('animations').length && !willStartAuto) {
|
if (!this.animationQueue.get('animations').length && !willStartAuto) {
|
||||||
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
AnimationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||||
}
|
}
|
||||||
|
|
||||||
// animation queue will call the callback when its done
|
// animation queue will call the callback when its done
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue