mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-25 15:38:33 +02:00
finally have get string now
This commit is contained in:
parent
f1752d115b
commit
f7af08c5fe
5 changed files with 117 additions and 115 deletions
|
@ -28,10 +28,10 @@ function GitEngine(options) {
|
|||
this.eventBaton = options.eventBaton;
|
||||
this.eventBaton.stealBaton('processGitCommand', this.dispatch, this);
|
||||
|
||||
// poor man's dependency injection
|
||||
if (options.animationFactory) {
|
||||
AnimationFactory = options.animationFactory;
|
||||
}
|
||||
// poor man's dependency injection. we cant reassign
|
||||
// the module variable because its get clobbered :P
|
||||
this.animationFactory = (options.animationFactory) ?
|
||||
options.animationFactory : AnimationFactory;
|
||||
|
||||
// global variable to keep track of the options given
|
||||
// along with the command call.
|
||||
|
@ -262,7 +262,7 @@ GitEngine.prototype.makeOrigin = function(treeString) {
|
|||
// and then here is the crazy part -- we need the ORIGIN to refresh
|
||||
// itself in a separate animation. @_____@
|
||||
this.origin.externalRefresh();
|
||||
AnimationFactory.playRefreshAnimationAndFinish(this.gitVisuals, this.animationQueue);
|
||||
this.animationFactory.playRefreshAnimationAndFinish(this.gitVisuals, this.animationQueue);
|
||||
}, this);
|
||||
|
||||
// we only clone from our current state, so we can safely assume all of our
|
||||
|
@ -611,7 +611,7 @@ GitEngine.prototype.revert = function(whichCommits) {
|
|||
var chain = deferred.promise;
|
||||
var destBranch = this.resolveID('HEAD');
|
||||
|
||||
chain = AnimationFactory.highlightEachWithPromise(
|
||||
chain = this.animationFactory.highlightEachWithPromise(
|
||||
chain,
|
||||
toRevert,
|
||||
destBranch
|
||||
|
@ -630,7 +630,7 @@ GitEngine.prototype.revert = function(whichCommits) {
|
|||
});
|
||||
base = newCommit;
|
||||
|
||||
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
||||
newCommit,
|
||||
this.gitVisuals
|
||||
);
|
||||
|
@ -646,7 +646,7 @@ GitEngine.prototype.revert = function(whichCommits) {
|
|||
// done! update our location
|
||||
chain = chain.then(_.bind(function() {
|
||||
this.setTargetLocation('HEAD', base);
|
||||
return AnimationFactory.playRefreshAnimation(this.gitVisuals);
|
||||
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
|
||||
}, this));
|
||||
|
||||
this.animationQueue.thenFinish(chain, deferred);
|
||||
|
@ -705,7 +705,7 @@ GitEngine.prototype.cherrypickStarter = function() {
|
|||
var chain = deferred.promise;
|
||||
var destinationBranch = this.resolveID('HEAD');
|
||||
|
||||
chain = AnimationFactory.highlightEachWithPromise(
|
||||
chain = this.animationFactory.highlightEachWithPromise(
|
||||
chain,
|
||||
toCherrypick,
|
||||
destinationBranch
|
||||
|
@ -713,7 +713,7 @@ GitEngine.prototype.cherrypickStarter = function() {
|
|||
|
||||
var chainStep = _.bind(function(commit) {
|
||||
var newCommit = this.cherrypick(commit);
|
||||
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
||||
newCommit,
|
||||
this.gitVisuals
|
||||
);
|
||||
|
@ -871,7 +871,7 @@ GitEngine.prototype.push = function(options) {
|
|||
// now make the promise chain to make each commit
|
||||
var chainStep = _.bind(function(id, parents) {
|
||||
var newCommit = makeCommit(id, parents);
|
||||
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
||||
newCommit,
|
||||
this.origin.gitVisuals
|
||||
);
|
||||
|
@ -882,7 +882,7 @@ GitEngine.prototype.push = function(options) {
|
|||
|
||||
_.each(commitsToMake, function(commitJSON) {
|
||||
chain = chain.then(_.bind(function() {
|
||||
return AnimationFactory.playHighlightPromiseAnimation(
|
||||
return this.animationFactory.playHighlightPromiseAnimation(
|
||||
this.refs[commitJSON.id],
|
||||
remoteBranch
|
||||
);
|
||||
|
@ -901,8 +901,8 @@ GitEngine.prototype.push = function(options) {
|
|||
var remoteCommit = this.origin.refs[localLocationID];
|
||||
this.origin.setTargetLocation(remoteBranch, remoteCommit);
|
||||
// unhighlight local
|
||||
AnimationFactory.playRefreshAnimation(this.gitVisuals);
|
||||
return AnimationFactory.playRefreshAnimation(this.origin.gitVisuals);
|
||||
this.animationFactory.playRefreshAnimation(this.gitVisuals);
|
||||
return this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
|
||||
}, this));
|
||||
|
||||
// HAX HAX update o/master
|
||||
|
@ -911,7 +911,7 @@ GitEngine.prototype.push = function(options) {
|
|||
var remoteBranchID = localBranch.getRemoteBranchIDFromTracking();
|
||||
// less hacks hax
|
||||
this.setTargetLocation(this.refs[remoteBranchID], localCommit);
|
||||
return AnimationFactory.playRefreshAnimation(this.gitVisuals);
|
||||
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
|
||||
}, this));
|
||||
|
||||
if (!options.dontResolvePromise) {
|
||||
|
@ -976,7 +976,7 @@ GitEngine.prototype.fetch = function(options) {
|
|||
// now make the promise chain to make each commit
|
||||
var chainStep = _.bind(function(id, parents) {
|
||||
var newCommit = makeCommit(id, parents);
|
||||
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
||||
newCommit,
|
||||
this.gitVisuals
|
||||
);
|
||||
|
@ -987,7 +987,7 @@ GitEngine.prototype.fetch = function(options) {
|
|||
|
||||
_.each(commitsToMake, function(commitJSON) {
|
||||
chain = chain.then(_.bind(function() {
|
||||
return AnimationFactory.playHighlightPromiseAnimation(
|
||||
return this.animationFactory.playHighlightPromiseAnimation(
|
||||
this.origin.refs[commitJSON.id],
|
||||
localBranch
|
||||
);
|
||||
|
@ -1006,8 +1006,8 @@ GitEngine.prototype.fetch = function(options) {
|
|||
var localCommit = this.refs[originLocationID];
|
||||
this.setTargetLocation(localBranch, localCommit);
|
||||
// unhighlight origin
|
||||
AnimationFactory.playRefreshAnimation(this.origin.gitVisuals);
|
||||
return AnimationFactory.playRefreshAnimation(this.gitVisuals);
|
||||
this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
|
||||
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
|
||||
}, this));
|
||||
|
||||
if (!options.dontResolvePromise) {
|
||||
|
@ -1058,13 +1058,13 @@ GitEngine.prototype.pullFinishWithRebase = function(
|
|||
// delay a bit after the intense refresh animation from
|
||||
// fetch
|
||||
chain = chain.then(function() {
|
||||
return AnimationFactory.getDelayedPromise(300);
|
||||
return this.animationFactory.getDelayedPromise(300);
|
||||
});
|
||||
|
||||
chain = chain.then(_.bind(function() {
|
||||
// highlight last commit on o/master to color of
|
||||
// local branch
|
||||
return AnimationFactory.playHighlightPromiseAnimation(
|
||||
return this.animationFactory.playHighlightPromiseAnimation(
|
||||
this.getCommitFromRef(remoteBranch),
|
||||
localBranch
|
||||
);
|
||||
|
@ -1089,13 +1089,13 @@ GitEngine.prototype.pullFinishWithMerge = function(
|
|||
// delay a bit after the intense refresh animation from
|
||||
// fetch
|
||||
chain = chain.then(function() {
|
||||
return AnimationFactory.getDelayedPromise(300);
|
||||
return this.animationFactory.getDelayedPromise(300);
|
||||
});
|
||||
|
||||
chain = chain.then(_.bind(function() {
|
||||
// highlight last commit on o/master to color of
|
||||
// local branch
|
||||
return AnimationFactory.playHighlightPromiseAnimation(
|
||||
return this.animationFactory.playHighlightPromiseAnimation(
|
||||
this.getCommitFromRef(remoteBranch),
|
||||
localBranch
|
||||
);
|
||||
|
@ -1103,7 +1103,7 @@ GitEngine.prototype.pullFinishWithMerge = function(
|
|||
|
||||
chain = chain.then(_.bind(function() {
|
||||
// highlight commit on master to color of remote
|
||||
return AnimationFactory.playHighlightPromiseAnimation(
|
||||
return this.animationFactory.playHighlightPromiseAnimation(
|
||||
this.getCommitFromRef(localBranch),
|
||||
remoteBranch
|
||||
);
|
||||
|
@ -1111,16 +1111,16 @@ GitEngine.prototype.pullFinishWithMerge = function(
|
|||
|
||||
// delay and merge
|
||||
chain = chain.then(function() {
|
||||
return AnimationFactory.getDelayedPromise(700);
|
||||
return this.animationFactory.getDelayedPromise(700);
|
||||
});
|
||||
chain = chain.then(_.bind(function() {
|
||||
var newCommit = this.merge('o/master');
|
||||
if (!newCommit) {
|
||||
// it is a fast forward
|
||||
return AnimationFactory.playRefreshAnimation(this.gitVisuals);
|
||||
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
|
||||
}
|
||||
|
||||
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
||||
newCommit,
|
||||
this.gitVisuals
|
||||
);
|
||||
|
@ -1164,7 +1164,7 @@ GitEngine.prototype.fakeTeamwork = function(numToMake, branch) {
|
|||
|
||||
var chainStep = _.bind(function() {
|
||||
var newCommit = makeOriginCommit();
|
||||
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
||||
newCommit,
|
||||
this.origin.gitVisuals
|
||||
);
|
||||
|
@ -1237,7 +1237,7 @@ GitEngine.prototype.commitStarter = function() {
|
|||
newCommit.set('commitMessage', msg);
|
||||
}
|
||||
|
||||
var promise = AnimationFactory.playCommitBirthPromiseAnimation(
|
||||
var promise = this.animationFactory.playCommitBirthPromiseAnimation(
|
||||
newCommit,
|
||||
this.gitVisuals
|
||||
);
|
||||
|
@ -1744,7 +1744,7 @@ GitEngine.prototype.rebaseFinish = function(
|
|||
});
|
||||
}
|
||||
|
||||
chain = AnimationFactory.highlightEachWithPromise(
|
||||
chain = this.animationFactory.highlightEachWithPromise(
|
||||
chain,
|
||||
toRebase,
|
||||
destinationBranch
|
||||
|
@ -1758,7 +1758,7 @@ GitEngine.prototype.rebaseFinish = function(
|
|||
var newCommit = this.makeCommit([base], newId);
|
||||
base = newCommit;
|
||||
|
||||
return AnimationFactory.playCommitBirthPromiseAnimation(
|
||||
return this.animationFactory.playCommitBirthPromiseAnimation(
|
||||
newCommit,
|
||||
this.gitVisuals
|
||||
);
|
||||
|
@ -1781,7 +1781,7 @@ GitEngine.prototype.rebaseFinish = function(
|
|||
this.setTargetLocation(currentLocation, base);
|
||||
this.checkout(currentLocation);
|
||||
}
|
||||
return AnimationFactory.playRefreshAnimation(this.gitVisuals);
|
||||
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
|
||||
}, this));
|
||||
|
||||
if (!options.dontResolvePromise) {
|
||||
|
@ -1797,11 +1797,11 @@ GitEngine.prototype.mergeStarter = function() {
|
|||
|
||||
if (newCommit === undefined) {
|
||||
// its just a fast forwrard
|
||||
AnimationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||
return;
|
||||
}
|
||||
|
||||
AnimationFactory.genCommitBirthAnimation(this.animationQueue, newCommit, this.gitVisuals);
|
||||
this.animationFactory.genCommitBirthAnimation(this.animationQueue, newCommit, this.gitVisuals);
|
||||
};
|
||||
|
||||
GitEngine.prototype.merge = function(targetSource) {
|
||||
|
@ -2041,7 +2041,7 @@ GitEngine.prototype.externalRefresh = function() {
|
|||
this.animationQueue = new AnimationQueue({
|
||||
callback: function() {}
|
||||
});
|
||||
AnimationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||
this.animationQueue.start();
|
||||
};
|
||||
|
||||
|
@ -2076,7 +2076,7 @@ GitEngine.prototype.dispatch = function(command, deferred) {
|
|||
|
||||
// only add the refresh if we didn't do manual animations
|
||||
if (!this.animationQueue.get('animations').length && !willStartAuto) {
|
||||
AnimationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||
this.animationFactory.refreshTree(this.animationQueue, this.gitVisuals);
|
||||
}
|
||||
|
||||
// animation queue will call the callback when its done
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue