mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 00:40:07 +02:00
moving to interactive rebasing
This commit is contained in:
parent
7e28fd8452
commit
0674d77fed
5 changed files with 50 additions and 17 deletions
|
@ -93,7 +93,6 @@ AnimationFactory.prototype.genCommitBirthClosureFromSnapshot = function(step) {
|
||||||
AnimationFactory.prototype.refreshTree = function(animationQueue) {
|
AnimationFactory.prototype.refreshTree = function(animationQueue) {
|
||||||
animationQueue.add(new Animation({
|
animationQueue.add(new Animation({
|
||||||
closure: function() {
|
closure: function() {
|
||||||
console.log('refreshing tree from here');
|
|
||||||
gitVisuals.refreshTree();
|
gitVisuals.refreshTree();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -23,7 +23,8 @@ var AnimationQueue = Backbone.Model.extend({
|
||||||
defaults: {
|
defaults: {
|
||||||
animations: null,
|
animations: null,
|
||||||
index: 0,
|
index: 0,
|
||||||
callback: null
|
callback: null,
|
||||||
|
defer: false
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
|
|
|
@ -264,7 +264,9 @@ OptionParser.prototype.getMasterOptionMap = function() {
|
||||||
'--soft': false, // this will raise an error but we catch it in gitEngine
|
'--soft': false, // this will raise an error but we catch it in gitEngine
|
||||||
},
|
},
|
||||||
merge: {},
|
merge: {},
|
||||||
rebase: {},
|
rebase: {
|
||||||
|
'-i': false // the mother of all options
|
||||||
|
},
|
||||||
revert: {},
|
revert: {},
|
||||||
show: {}
|
show: {}
|
||||||
};
|
};
|
||||||
|
|
58
src/git.js
58
src/git.js
|
@ -443,7 +443,7 @@ GitEngine.prototype.commitStarter = function() {
|
||||||
|
|
||||||
if (this.commandOptions['-am']) {
|
if (this.commandOptions['-am']) {
|
||||||
var args = this.commandOptions['-am'];
|
var args = this.commandOptions['-am'];
|
||||||
this.validateArgBounds(args, 1, 1);
|
this.validateArgBounds(args, 1, 1, '-am');
|
||||||
|
|
||||||
this.command.addWarning("Don't worry about adding files in this demo. I'll take " +
|
this.command.addWarning("Don't worry about adding files in this demo. I'll take " +
|
||||||
"down your commit message anyways, but you can commit without a message " +
|
"down your commit message anyways, but you can commit without a message " +
|
||||||
|
@ -453,7 +453,7 @@ GitEngine.prototype.commitStarter = function() {
|
||||||
|
|
||||||
if (this.commandOptions['-m']) {
|
if (this.commandOptions['-m']) {
|
||||||
var args = this.commandOptions['-m'];
|
var args = this.commandOptions['-m'];
|
||||||
this.validateArgBounds(args, 1, 1);
|
this.validateArgBounds(args, 1, 1, '-m');
|
||||||
msg = args[0];
|
msg = args[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -739,7 +739,21 @@ GitEngine.prototype.idSortFunc = function(cA, cB) {
|
||||||
return getNumToSort(cA.get('id')) - getNumToSort(cB.get('id'));
|
return getNumToSort(cA.get('id')) - getNumToSort(cB.get('id'));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GitEngine.prototype.rebaseInteractiveStarter = function() {
|
||||||
|
// first of all, our animation queue will be deferred because now its async
|
||||||
|
this.animationQueue.set('defer', true);
|
||||||
|
|
||||||
|
this.twoArgsImpliedHead(this.commandOptions['-i'], 1, 1, '-i');
|
||||||
|
|
||||||
|
// now do stuff :D
|
||||||
|
};
|
||||||
|
|
||||||
GitEngine.prototype.rebaseStarter = function() {
|
GitEngine.prototype.rebaseStarter = function() {
|
||||||
|
if (this.commandOptions['-i']) {
|
||||||
|
this.rebaseInteractiveStarter();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.twoArgsImpliedHead(this.generalArgs);
|
this.twoArgsImpliedHead(this.generalArgs);
|
||||||
|
|
||||||
var response = this.rebase(this.generalArgs[0], this.generalArgs[1]);
|
var response = this.rebase(this.generalArgs[0], this.generalArgs[1]);
|
||||||
|
@ -779,16 +793,12 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var animationResponse = {};
|
// now the part of actually rebasing.
|
||||||
animationResponse.destinationBranch = this.resolveID(targetSource);
|
|
||||||
|
|
||||||
// now the part of actually rebasing.
|
|
||||||
// We need to get the downstream set of targetSource first.
|
// We need to get the downstream set of targetSource first.
|
||||||
// then we BFS from currentLocation, using the downstream set as our stopping point.
|
// then we BFS from currentLocation, using the downstream set as our stopping point.
|
||||||
// we need to BFS because we need to include all commits below
|
// we need to BFS because we need to include all commits below
|
||||||
// pop these commits on top of targetSource and modify their ids with quotes
|
// pop these commits on top of targetSource and modify their ids with quotes
|
||||||
var stopSet = this.getUpstreamSet(targetSource)
|
var stopSet = this.getUpstreamSet(targetSource)
|
||||||
animationResponse.upstreamSet = stopSet;
|
|
||||||
|
|
||||||
// now BFS from here on out
|
// now BFS from here on out
|
||||||
var toRebaseRough = [];
|
var toRebaseRough = [];
|
||||||
|
@ -809,7 +819,14 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation) {
|
||||||
// pQueue.sort(this.idSortFunc);
|
// pQueue.sort(this.idSortFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now we have the all the commits between currentLocation and the set of target.
|
return this.rebaseFinish(toRebaseRough, stopSet, targetSource, currentLocation);
|
||||||
|
};
|
||||||
|
|
||||||
|
GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource, currentLocation) {
|
||||||
|
|
||||||
|
// now we have the all the commits between currentLocation and the set of target to rebase.
|
||||||
|
var animationResponse = {};
|
||||||
|
animationResponse.destinationBranch = this.resolveID(targetSource);
|
||||||
|
|
||||||
// we need to throw out merge commits
|
// we need to throw out merge commits
|
||||||
var toRebase = [];
|
var toRebase = [];
|
||||||
|
@ -827,7 +844,7 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation) {
|
||||||
changesAlreadyMade[this.scrapeBaseID(key)] = val; // val == true
|
changesAlreadyMade[this.scrapeBaseID(key)] = val; // val == true
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
// now get rid of those other ones
|
// now get rid of the commits that will redo same changes
|
||||||
toRebaseRough = toRebase;
|
toRebaseRough = toRebase;
|
||||||
toRebase = [];
|
toRebase = [];
|
||||||
_.each(toRebaseRough, function(commit) {
|
_.each(toRebaseRough, function(commit) {
|
||||||
|
@ -871,9 +888,20 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation) {
|
||||||
beforeSnapshot = afterSnapshot;
|
beforeSnapshot = afterSnapshot;
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
// now we just need to update the rebased branch is
|
if (this.resolveID(currentLocation).get('type') == 'commit') {
|
||||||
this.setTargetLocation(currentLocation, base);
|
// we referenced a commit like git rebase C2 C1, so we have
|
||||||
this.checkout(currentLocation);
|
// to manually check out C1'
|
||||||
|
|
||||||
|
var steps = animationResponse.rebaseSteps;
|
||||||
|
var newestCommit = steps[steps.length - 1].newCommit;
|
||||||
|
|
||||||
|
this.checkout(newestCommit);
|
||||||
|
} else {
|
||||||
|
// now we just need to update the rebased branch is
|
||||||
|
this.setTargetLocation(currentLocation, base);
|
||||||
|
this.checkout(currentLocation);
|
||||||
|
}
|
||||||
|
|
||||||
// for animation
|
// for animation
|
||||||
return animationResponse;
|
return animationResponse;
|
||||||
};
|
};
|
||||||
|
@ -972,7 +1000,7 @@ GitEngine.prototype.branchStarter = function() {
|
||||||
// handle deletion first
|
// handle deletion first
|
||||||
if (this.commandOptions['-d'] || this.commandOptions['-D']) {
|
if (this.commandOptions['-d'] || this.commandOptions['-D']) {
|
||||||
var names = this.commandOptions['-d'] || this.commandOptions['-D'];
|
var names = this.commandOptions['-d'] || this.commandOptions['-D'];
|
||||||
this.validateArgBounds(names, 1, NaN);
|
this.validateArgBounds(names, 1, NaN, '-d');
|
||||||
|
|
||||||
_.each(names, function(name) {
|
_.each(names, function(name) {
|
||||||
this.deleteBranch(name);
|
this.deleteBranch(name);
|
||||||
|
@ -1098,7 +1126,9 @@ GitEngine.prototype.dispatch = function(command, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// animation queue will call the callback when its done
|
// animation queue will call the callback when its done
|
||||||
this.animationQueue.start();
|
if (!this.animationQueue.get('defer')) {
|
||||||
|
this.animationQueue.start();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.showStarter = function() {
|
GitEngine.prototype.showStarter = function() {
|
||||||
|
|
1
todo.txt
1
todo.txt
|
@ -6,6 +6,7 @@ Big things:
|
||||||
Big Graphic things:
|
Big Graphic things:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
- gitVisuals OVERHAUL. Will make the load / save tree easier
|
- gitVisuals OVERHAUL. Will make the load / save tree easier
|
||||||
|
- Callback animations?
|
||||||
|
|
||||||
Medium things:
|
Medium things:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue