mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-26 16:08:34 +02:00
Added testable interactive rebase. It doesn't fully test everything (mainly the GUI), but is a start
This commit is contained in:
parent
55ac6da589
commit
72cc7d6bd3
2 changed files with 71 additions and 14 deletions
|
@ -569,6 +569,7 @@ var commandConfig = {
|
||||||
sc: /^gr($|\s)/,
|
sc: /^gr($|\s)/,
|
||||||
options: [
|
options: [
|
||||||
'-i',
|
'-i',
|
||||||
|
'--interactive-test',
|
||||||
'--aboveAll',
|
'--aboveAll',
|
||||||
'-p',
|
'-p',
|
||||||
'--preserve-merges'
|
'--preserve-merges'
|
||||||
|
@ -581,12 +582,23 @@ var commandConfig = {
|
||||||
if (commandOptions['-i']) {
|
if (commandOptions['-i']) {
|
||||||
var args = commandOptions['-i'].concat(generalArgs);
|
var args = commandOptions['-i'].concat(generalArgs);
|
||||||
command.twoArgsImpliedHead(args, ' -i');
|
command.twoArgsImpliedHead(args, ' -i');
|
||||||
|
|
||||||
|
if (commandOptions['--interactive-test']) {
|
||||||
|
engine.rebaseInteractiveTest(
|
||||||
|
args[0],
|
||||||
|
args[1], {
|
||||||
|
interactiveTest: commandOptions['--interactive-test']
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
engine.rebaseInteractive(
|
engine.rebaseInteractive(
|
||||||
args[0],
|
args[0],
|
||||||
args[1], {
|
args[1], {
|
||||||
aboveAll: !!commandOptions['--aboveAll']
|
aboveAll: !!commandOptions['--aboveAll'],
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2070,15 +2070,10 @@ GitEngine.prototype.getUpstreamDiffFromSet = function(stopSet, location) {
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.rebaseInteractive = function(targetSource, currentLocation, options) {
|
GitEngine.prototype.getInteractiveRebaseCommits = function(targetSource, currentLocation) {
|
||||||
options = options || {};
|
|
||||||
// there are a reduced set of checks now, so we can't exactly use parts of the rebase function
|
|
||||||
// but it will look similar.
|
|
||||||
|
|
||||||
// now get the stop set
|
|
||||||
var stopSet = Graph.getUpstreamSet(this, targetSource);
|
var stopSet = Graph.getUpstreamSet(this, targetSource);
|
||||||
|
|
||||||
var toRebaseRough = [];
|
var toRebaseRough = [];
|
||||||
|
|
||||||
// standard BFS
|
// standard BFS
|
||||||
var pQueue = [this.getCommitFromRef(currentLocation)];
|
var pQueue = [this.getCommitFromRef(currentLocation)];
|
||||||
|
|
||||||
|
@ -2108,6 +2103,56 @@ GitEngine.prototype.rebaseInteractive = function(targetSource, currentLocation,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return toRebase;
|
||||||
|
};
|
||||||
|
|
||||||
|
GitEngine.prototype.rebaseInteractiveTest = function(targetSource, currentLocation, options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
// Get the list of commits that would be displayed to the user
|
||||||
|
var toRebase = this.getInteractiveRebaseCommits(targetSource, currentLocation);
|
||||||
|
|
||||||
|
var rebaseMap = {};
|
||||||
|
_.each(toRebase, function(commit) {
|
||||||
|
var id = commit.get('id');
|
||||||
|
rebaseMap[id] = commit;
|
||||||
|
});
|
||||||
|
|
||||||
|
var rebaseOrder;
|
||||||
|
if (options['interactiveTest'].length === 0) {
|
||||||
|
// If no commits were explicitly specified for the rebase, act like the user didn't change anything
|
||||||
|
// in the rebase dialog and hit confirm
|
||||||
|
rebaseOrder = toRebase;
|
||||||
|
} else {
|
||||||
|
// Get the list and order of commits specified
|
||||||
|
var idsToRebase = options['interactiveTest'][0].split(',');
|
||||||
|
|
||||||
|
// Verify each chosen commit exists in the list of commits given to the user
|
||||||
|
var extraCommits = [];
|
||||||
|
rebaseOrder = [];
|
||||||
|
_.each(idsToRebase, function(id) {
|
||||||
|
if (id in rebaseMap) {
|
||||||
|
rebaseOrder.push(rebaseMap[id]);
|
||||||
|
} else {
|
||||||
|
extraCommits.push(id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (extraCommits.length > 0) {
|
||||||
|
// What to do here?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.rebaseFinish(rebaseOrder, {}, targetSource, currentLocation);
|
||||||
|
};
|
||||||
|
|
||||||
|
GitEngine.prototype.rebaseInteractive = function(targetSource, currentLocation, options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
// there are a reduced set of checks now, so we can't exactly use parts of the rebase function
|
||||||
|
// but it will look similar.
|
||||||
|
var toRebase = this.getInteractiveRebaseCommits(targetSource, currentLocation);
|
||||||
|
|
||||||
// now do stuff :D since all our validation checks have passed, we are going to defer animation
|
// now do stuff :D since all our validation checks have passed, we are going to defer animation
|
||||||
// and actually launch the dialog
|
// and actually launch the dialog
|
||||||
this.animationQueue.set('defer', true);
|
this.animationQueue.set('defer', true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue