mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-26 16:08:34 +02:00
revert partway
This commit is contained in:
parent
ec1bab114f
commit
2e10b6c173
3 changed files with 63 additions and 107 deletions
106
build/bundle.js
106
build/bundle.js
|
@ -7647,11 +7647,7 @@ GitEngine.prototype.twoArgsImpliedHead = function(args, option) {
|
||||||
GitEngine.prototype.revertStarter = function() {
|
GitEngine.prototype.revertStarter = function() {
|
||||||
this.validateArgBounds(this.generalArgs, 1, NaN);
|
this.validateArgBounds(this.generalArgs, 1, NaN);
|
||||||
|
|
||||||
var response = this.revert(this.generalArgs);
|
this.revert(this.generalArgs);
|
||||||
|
|
||||||
if (response) {
|
|
||||||
this.animationFactory.rebaseAnimation(this.animationQueue, response, this, this.gitVisuals);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.revert = function(whichCommits) {
|
GitEngine.prototype.revert = function(whichCommits) {
|
||||||
|
@ -7674,46 +7670,35 @@ GitEngine.prototype.revert = function(whichCommits) {
|
||||||
}, this));
|
}, this));
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
// we animate reverts now!! we use the rebase animation though so that's
|
|
||||||
// why the terminology is like it is
|
|
||||||
var animationResponse = {};
|
|
||||||
animationResponse.destinationBranch = this.resolveID(toRebase[0]);
|
|
||||||
animationResponse.toRebaseArray = toRebase.slice(0);
|
|
||||||
animationResponse.rebaseSteps = [];
|
|
||||||
|
|
||||||
var beforeSnapshot = this.gitVisuals.genSnapshot();
|
|
||||||
var afterSnapshot;
|
|
||||||
|
|
||||||
// now make a bunch of commits on top of where we are
|
|
||||||
var base = this.getCommitFromRef('HEAD');
|
var base = this.getCommitFromRef('HEAD');
|
||||||
_.each(toRebase, function(oldCommit) {
|
// each step makes a new commit
|
||||||
|
var chainStep = _.bind(function(oldCommit) {
|
||||||
var newId = this.rebaseAltID(oldCommit.get('id'));
|
var newId = this.rebaseAltID(oldCommit.get('id'));
|
||||||
|
|
||||||
var commitMessage = intl.str('git-revert-msg', {
|
var commitMessage = intl.str('git-revert-msg', {
|
||||||
oldCommit: this.resolveName(oldCommit),
|
oldCommit: this.resolveName(oldCommit),
|
||||||
oldMsg: oldCommit.get('commitMessage')
|
oldMsg: oldCommit.get('commitMessage')
|
||||||
});
|
});
|
||||||
|
|
||||||
var newCommit = this.makeCommit([base], newId, {
|
var newCommit = this.makeCommit([base], newId, {
|
||||||
commitMessage: commitMessage
|
commitMessage: commitMessage
|
||||||
});
|
});
|
||||||
|
|
||||||
base = newCommit;
|
base = newCommit;
|
||||||
// animation stuff
|
|
||||||
afterSnapshot = this.gitVisuals.genSnapshot();
|
|
||||||
animationResponse.rebaseSteps.push({
|
|
||||||
oldCommit: oldCommit,
|
|
||||||
newCommit: newCommit,
|
|
||||||
beforeSnapshot: beforeSnapshot,
|
|
||||||
afterSnapshot: afterSnapshot
|
|
||||||
});
|
|
||||||
beforeSnapshot = afterSnapshot;
|
|
||||||
}, this);
|
|
||||||
// done! update our location
|
|
||||||
this.setTargetLocation('HEAD', base);
|
|
||||||
|
|
||||||
// animation
|
return this.animationFactory.playCommitBirthPromiseAnimation(
|
||||||
return animationResponse;
|
newCommit,
|
||||||
|
this.gitVisuals
|
||||||
|
);
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
// set up the promise chain
|
||||||
|
_.each(whichCommits, function(commit) {
|
||||||
|
chain = chain.then(function() {
|
||||||
|
chainStep(commit);
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
// done! update our location
|
||||||
|
// this.setTargetLocation('HEAD', base);
|
||||||
|
this.animationQueue.thenFinish(chain);
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.resetStarter = function() {
|
GitEngine.prototype.resetStarter = function() {
|
||||||
|
@ -23602,11 +23587,7 @@ GitEngine.prototype.twoArgsImpliedHead = function(args, option) {
|
||||||
GitEngine.prototype.revertStarter = function() {
|
GitEngine.prototype.revertStarter = function() {
|
||||||
this.validateArgBounds(this.generalArgs, 1, NaN);
|
this.validateArgBounds(this.generalArgs, 1, NaN);
|
||||||
|
|
||||||
var response = this.revert(this.generalArgs);
|
this.revert(this.generalArgs);
|
||||||
|
|
||||||
if (response) {
|
|
||||||
this.animationFactory.rebaseAnimation(this.animationQueue, response, this, this.gitVisuals);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.revert = function(whichCommits) {
|
GitEngine.prototype.revert = function(whichCommits) {
|
||||||
|
@ -23629,46 +23610,35 @@ GitEngine.prototype.revert = function(whichCommits) {
|
||||||
}, this));
|
}, this));
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
// we animate reverts now!! we use the rebase animation though so that's
|
|
||||||
// why the terminology is like it is
|
|
||||||
var animationResponse = {};
|
|
||||||
animationResponse.destinationBranch = this.resolveID(toRebase[0]);
|
|
||||||
animationResponse.toRebaseArray = toRebase.slice(0);
|
|
||||||
animationResponse.rebaseSteps = [];
|
|
||||||
|
|
||||||
var beforeSnapshot = this.gitVisuals.genSnapshot();
|
|
||||||
var afterSnapshot;
|
|
||||||
|
|
||||||
// now make a bunch of commits on top of where we are
|
|
||||||
var base = this.getCommitFromRef('HEAD');
|
var base = this.getCommitFromRef('HEAD');
|
||||||
_.each(toRebase, function(oldCommit) {
|
// each step makes a new commit
|
||||||
|
var chainStep = _.bind(function(oldCommit) {
|
||||||
var newId = this.rebaseAltID(oldCommit.get('id'));
|
var newId = this.rebaseAltID(oldCommit.get('id'));
|
||||||
|
|
||||||
var commitMessage = intl.str('git-revert-msg', {
|
var commitMessage = intl.str('git-revert-msg', {
|
||||||
oldCommit: this.resolveName(oldCommit),
|
oldCommit: this.resolveName(oldCommit),
|
||||||
oldMsg: oldCommit.get('commitMessage')
|
oldMsg: oldCommit.get('commitMessage')
|
||||||
});
|
});
|
||||||
|
|
||||||
var newCommit = this.makeCommit([base], newId, {
|
var newCommit = this.makeCommit([base], newId, {
|
||||||
commitMessage: commitMessage
|
commitMessage: commitMessage
|
||||||
});
|
});
|
||||||
|
|
||||||
base = newCommit;
|
base = newCommit;
|
||||||
// animation stuff
|
|
||||||
afterSnapshot = this.gitVisuals.genSnapshot();
|
|
||||||
animationResponse.rebaseSteps.push({
|
|
||||||
oldCommit: oldCommit,
|
|
||||||
newCommit: newCommit,
|
|
||||||
beforeSnapshot: beforeSnapshot,
|
|
||||||
afterSnapshot: afterSnapshot
|
|
||||||
});
|
|
||||||
beforeSnapshot = afterSnapshot;
|
|
||||||
}, this);
|
|
||||||
// done! update our location
|
|
||||||
this.setTargetLocation('HEAD', base);
|
|
||||||
|
|
||||||
// animation
|
return this.animationFactory.playCommitBirthPromiseAnimation(
|
||||||
return animationResponse;
|
newCommit,
|
||||||
|
this.gitVisuals
|
||||||
|
);
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
// set up the promise chain
|
||||||
|
_.each(whichCommits, function(commit) {
|
||||||
|
chain = chain.then(function() {
|
||||||
|
chainStep(commit);
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
// done! update our location
|
||||||
|
// this.setTargetLocation('HEAD', base);
|
||||||
|
this.animationQueue.thenFinish(chain);
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.resetStarter = function() {
|
GitEngine.prototype.resetStarter = function() {
|
||||||
|
|
|
@ -594,11 +594,7 @@ GitEngine.prototype.twoArgsImpliedHead = function(args, option) {
|
||||||
GitEngine.prototype.revertStarter = function() {
|
GitEngine.prototype.revertStarter = function() {
|
||||||
this.validateArgBounds(this.generalArgs, 1, NaN);
|
this.validateArgBounds(this.generalArgs, 1, NaN);
|
||||||
|
|
||||||
var response = this.revert(this.generalArgs);
|
this.revert(this.generalArgs);
|
||||||
|
|
||||||
if (response) {
|
|
||||||
this.animationFactory.rebaseAnimation(this.animationQueue, response, this, this.gitVisuals);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.revert = function(whichCommits) {
|
GitEngine.prototype.revert = function(whichCommits) {
|
||||||
|
@ -621,46 +617,35 @@ GitEngine.prototype.revert = function(whichCommits) {
|
||||||
}, this));
|
}, this));
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
// we animate reverts now!! we use the rebase animation though so that's
|
|
||||||
// why the terminology is like it is
|
|
||||||
var animationResponse = {};
|
|
||||||
animationResponse.destinationBranch = this.resolveID(toRebase[0]);
|
|
||||||
animationResponse.toRebaseArray = toRebase.slice(0);
|
|
||||||
animationResponse.rebaseSteps = [];
|
|
||||||
|
|
||||||
var beforeSnapshot = this.gitVisuals.genSnapshot();
|
|
||||||
var afterSnapshot;
|
|
||||||
|
|
||||||
// now make a bunch of commits on top of where we are
|
|
||||||
var base = this.getCommitFromRef('HEAD');
|
var base = this.getCommitFromRef('HEAD');
|
||||||
_.each(toRebase, function(oldCommit) {
|
// each step makes a new commit
|
||||||
|
var chainStep = _.bind(function(oldCommit) {
|
||||||
var newId = this.rebaseAltID(oldCommit.get('id'));
|
var newId = this.rebaseAltID(oldCommit.get('id'));
|
||||||
|
|
||||||
var commitMessage = intl.str('git-revert-msg', {
|
var commitMessage = intl.str('git-revert-msg', {
|
||||||
oldCommit: this.resolveName(oldCommit),
|
oldCommit: this.resolveName(oldCommit),
|
||||||
oldMsg: oldCommit.get('commitMessage')
|
oldMsg: oldCommit.get('commitMessage')
|
||||||
});
|
});
|
||||||
|
|
||||||
var newCommit = this.makeCommit([base], newId, {
|
var newCommit = this.makeCommit([base], newId, {
|
||||||
commitMessage: commitMessage
|
commitMessage: commitMessage
|
||||||
});
|
});
|
||||||
|
|
||||||
base = newCommit;
|
base = newCommit;
|
||||||
// animation stuff
|
|
||||||
afterSnapshot = this.gitVisuals.genSnapshot();
|
|
||||||
animationResponse.rebaseSteps.push({
|
|
||||||
oldCommit: oldCommit,
|
|
||||||
newCommit: newCommit,
|
|
||||||
beforeSnapshot: beforeSnapshot,
|
|
||||||
afterSnapshot: afterSnapshot
|
|
||||||
});
|
|
||||||
beforeSnapshot = afterSnapshot;
|
|
||||||
}, this);
|
|
||||||
// done! update our location
|
|
||||||
this.setTargetLocation('HEAD', base);
|
|
||||||
|
|
||||||
// animation
|
return this.animationFactory.playCommitBirthPromiseAnimation(
|
||||||
return animationResponse;
|
newCommit,
|
||||||
|
this.gitVisuals
|
||||||
|
);
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
// set up the promise chain
|
||||||
|
_.each(whichCommits, function(commit) {
|
||||||
|
chain = chain.then(function() {
|
||||||
|
chainStep(commit);
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
// done! update our location
|
||||||
|
// this.setTargetLocation('HEAD', base);
|
||||||
|
this.animationQueue.thenFinish(chain, deferred);
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.resetStarter = function() {
|
GitEngine.prototype.resetStarter = function() {
|
||||||
|
@ -866,9 +851,7 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
|
||||||
return chainStep();
|
return chainStep();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.animationQueue.thenFinish(chain);
|
this.animationQueue.thenFinish(chain, deferred);
|
||||||
|
|
||||||
deferred.resolve();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.receiveTeamwork = function(id, animationQueue) {
|
GitEngine.prototype.receiveTeamwork = function(id, animationQueue) {
|
||||||
|
@ -932,7 +915,7 @@ GitEngine.prototype.commitStarter = function() {
|
||||||
newCommit,
|
newCommit,
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
);
|
);
|
||||||
this.animationQueue.thenFinish(promise);
|
this.animationQueue.thenFinish(promise, deferred);
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.commit = function() {
|
GitEngine.prototype.commit = function() {
|
||||||
|
|
|
@ -40,11 +40,14 @@ var AnimationQueue = Backbone.Model.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
thenFinish: function(promise) {
|
thenFinish: function(promise, deferred) {
|
||||||
promise.then(_.bind(function() {
|
promise.then(_.bind(function() {
|
||||||
this.finish();
|
this.finish();
|
||||||
}, this));
|
}, this));
|
||||||
this.set('promiseBased', true);
|
this.set('promiseBased', true);
|
||||||
|
if (deferred) {
|
||||||
|
deferred.resolve();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
add: function(animation) {
|
add: function(animation) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue