mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-04 03:34:27 +02:00
rebuild with awesome new test coverage
This commit is contained in:
parent
e409c44ab3
commit
7a00bd09f6
7 changed files with 89 additions and 70 deletions
|
@ -9870,22 +9870,56 @@ TreeCompare.onlyMasterCompared = function(levelBlob) {
|
||||||
};
|
};
|
||||||
|
|
||||||
TreeCompare.dispatch = function(levelBlob, goalTreeString, treeToCompare) {
|
TreeCompare.dispatch = function(levelBlob, goalTreeString, treeToCompare) {
|
||||||
|
var goalTree = this.convertTreeSafe(goalTreeString);
|
||||||
|
treeToCompare = this.convertTreeSafe(treeToCompare);
|
||||||
|
if (typeof goalTree.originTree !== typeof treeToCompare.originTree) {
|
||||||
|
// origin status does not match
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var shallowResult = this.dispatchShallow(
|
||||||
|
levelBlob, goalTree, treeToCompare
|
||||||
|
);
|
||||||
|
if (!shallowResult || !goalTree.originTree) {
|
||||||
|
// we only have one level (or failed on shallow), punt
|
||||||
|
return shallowResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
var originBlob = (levelBlob.originCompare) ?
|
||||||
|
levelBlob.originCompare : levelBlob;
|
||||||
|
// compare origin trees
|
||||||
|
return shallowResult && this.dispatchShallow(
|
||||||
|
originBlob, goalTree.originTree, treeToCompare.originTree
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
TreeCompare.dispatchShallow = function(levelBlob, goalTreeString, treeToCompare) {
|
||||||
var getAroundLintTrue = true;
|
var getAroundLintTrue = true;
|
||||||
// i actually prefer this to else if
|
// i actually prefer this to else if
|
||||||
switch (getAroundLintTrue) {
|
switch (getAroundLintTrue) {
|
||||||
case !!levelBlob.compareOnlyMaster:
|
case !!levelBlob.compareOnlyMaster:
|
||||||
return TreeCompare.compareBranchWithinTrees(treeToCompare, goalTreeString, 'master');
|
return TreeCompare.compareBranchWithinTrees(
|
||||||
|
treeToCompare, goalTreeString, 'master'
|
||||||
|
);
|
||||||
case !!levelBlob.compareOnlyBranches:
|
case !!levelBlob.compareOnlyBranches:
|
||||||
return TreeCompare.compareAllBranchesWithinTrees(treeToCompare, goalTreeString);
|
return TreeCompare.compareAllBranchesWithinTrees(
|
||||||
|
treeToCompare, goalTreeString
|
||||||
|
);
|
||||||
case !!levelBlob.compareAllBranchesHashAgnostic:
|
case !!levelBlob.compareAllBranchesHashAgnostic:
|
||||||
return TreeCompare.compareAllBranchesWithinTreesHashAgnostic(treeToCompare, goalTreeString);
|
return TreeCompare.compareAllBranchesWithinTreesHashAgnostic(
|
||||||
|
treeToCompare, goalTreeString
|
||||||
|
);
|
||||||
case !!levelBlob.compareOnlyMasterHashAgnostic:
|
case !!levelBlob.compareOnlyMasterHashAgnostic:
|
||||||
return TreeCompare.compareBranchesWithinTreesHashAgnostic(treeToCompare, goalTreeString, ['master']);
|
return TreeCompare.compareBranchesWithinTreesHashAgnostic(
|
||||||
|
treeToCompare, goalTreeString, ['master']
|
||||||
|
);
|
||||||
case !!levelBlob.compareOnlyMasterHashAgnosticWithAsserts:
|
case !!levelBlob.compareOnlyMasterHashAgnosticWithAsserts:
|
||||||
return TreeCompare.compareBranchesWithinTreesHashAgnostic(treeToCompare, goalTreeString, ['master']) &&
|
return TreeCompare.compareBranchesWithinTreesHashAgnostic(
|
||||||
TreeCompare.evalAsserts(treeToCompare, levelBlob.goalAsserts);
|
treeToCompare, goalTreeString, ['master']
|
||||||
|
) && TreeCompare.evalAsserts(treeToCompare, levelBlob.goalAsserts);
|
||||||
default:
|
default:
|
||||||
return TreeCompare.compareAllBranchesWithinTreesAndHEAD(treeToCompare, goalTreeString);
|
return TreeCompare.compareAllBranchesWithinTreesAndHEAD(
|
||||||
|
treeToCompare, goalTreeString
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -26134,22 +26168,56 @@ TreeCompare.onlyMasterCompared = function(levelBlob) {
|
||||||
};
|
};
|
||||||
|
|
||||||
TreeCompare.dispatch = function(levelBlob, goalTreeString, treeToCompare) {
|
TreeCompare.dispatch = function(levelBlob, goalTreeString, treeToCompare) {
|
||||||
|
var goalTree = this.convertTreeSafe(goalTreeString);
|
||||||
|
treeToCompare = this.convertTreeSafe(treeToCompare);
|
||||||
|
if (typeof goalTree.originTree !== typeof treeToCompare.originTree) {
|
||||||
|
// origin status does not match
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var shallowResult = this.dispatchShallow(
|
||||||
|
levelBlob, goalTree, treeToCompare
|
||||||
|
);
|
||||||
|
if (!shallowResult || !goalTree.originTree) {
|
||||||
|
// we only have one level (or failed on shallow), punt
|
||||||
|
return shallowResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
var originBlob = (levelBlob.originCompare) ?
|
||||||
|
levelBlob.originCompare : levelBlob;
|
||||||
|
// compare origin trees
|
||||||
|
return shallowResult && this.dispatchShallow(
|
||||||
|
originBlob, goalTree.originTree, treeToCompare.originTree
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
TreeCompare.dispatchShallow = function(levelBlob, goalTreeString, treeToCompare) {
|
||||||
var getAroundLintTrue = true;
|
var getAroundLintTrue = true;
|
||||||
// i actually prefer this to else if
|
// i actually prefer this to else if
|
||||||
switch (getAroundLintTrue) {
|
switch (getAroundLintTrue) {
|
||||||
case !!levelBlob.compareOnlyMaster:
|
case !!levelBlob.compareOnlyMaster:
|
||||||
return TreeCompare.compareBranchWithinTrees(treeToCompare, goalTreeString, 'master');
|
return TreeCompare.compareBranchWithinTrees(
|
||||||
|
treeToCompare, goalTreeString, 'master'
|
||||||
|
);
|
||||||
case !!levelBlob.compareOnlyBranches:
|
case !!levelBlob.compareOnlyBranches:
|
||||||
return TreeCompare.compareAllBranchesWithinTrees(treeToCompare, goalTreeString);
|
return TreeCompare.compareAllBranchesWithinTrees(
|
||||||
|
treeToCompare, goalTreeString
|
||||||
|
);
|
||||||
case !!levelBlob.compareAllBranchesHashAgnostic:
|
case !!levelBlob.compareAllBranchesHashAgnostic:
|
||||||
return TreeCompare.compareAllBranchesWithinTreesHashAgnostic(treeToCompare, goalTreeString);
|
return TreeCompare.compareAllBranchesWithinTreesHashAgnostic(
|
||||||
|
treeToCompare, goalTreeString
|
||||||
|
);
|
||||||
case !!levelBlob.compareOnlyMasterHashAgnostic:
|
case !!levelBlob.compareOnlyMasterHashAgnostic:
|
||||||
return TreeCompare.compareBranchesWithinTreesHashAgnostic(treeToCompare, goalTreeString, ['master']);
|
return TreeCompare.compareBranchesWithinTreesHashAgnostic(
|
||||||
|
treeToCompare, goalTreeString, ['master']
|
||||||
|
);
|
||||||
case !!levelBlob.compareOnlyMasterHashAgnosticWithAsserts:
|
case !!levelBlob.compareOnlyMasterHashAgnosticWithAsserts:
|
||||||
return TreeCompare.compareBranchesWithinTreesHashAgnostic(treeToCompare, goalTreeString, ['master']) &&
|
return TreeCompare.compareBranchesWithinTreesHashAgnostic(
|
||||||
TreeCompare.evalAsserts(treeToCompare, levelBlob.goalAsserts);
|
treeToCompare, goalTreeString, ['master']
|
||||||
|
) && TreeCompare.evalAsserts(treeToCompare, levelBlob.goalAsserts);
|
||||||
default:
|
default:
|
||||||
return TreeCompare.compareAllBranchesWithinTreesAndHEAD(treeToCompare, goalTreeString);
|
return TreeCompare.compareAllBranchesWithinTreesAndHEAD(
|
||||||
|
treeToCompare, goalTreeString
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
1
build/bundle.min.0cc3ab99.js
Normal file
1
build/bundle.min.0cc3ab99.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
build/bundle.min.js
vendored
2
build/bundle.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -434,7 +434,7 @@
|
||||||
For a much easier time perusing the source, see the individual files at:
|
For a much easier time perusing the source, see the individual files at:
|
||||||
https://github.com/pcottle/learnGitBranching
|
https://github.com/pcottle/learnGitBranching
|
||||||
-->
|
-->
|
||||||
<script src="build/bundle.min.fe16b80c.js"></script>
|
<script src="build/bundle.min.0cc3ab99.js"></script>
|
||||||
|
|
||||||
<!-- The advantage of github pages: super-easy, simple, slick static hostic.
|
<!-- The advantage of github pages: super-easy, simple, slick static hostic.
|
||||||
The downside? No raw logs to parse for analytics, so I have to include
|
The downside? No raw logs to parse for analytics, so I have to include
|
||||||
|
|
|
@ -129,8 +129,10 @@ describe('GitEngine', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does a whole bunch of crazy merging', function() {
|
it('does a whole bunch of crazy merging', function() {
|
||||||
"gc;go -b side C1;gc;git merge master;go -b bug master;gc;go -b wut C3;git rebase bug;go side;git rebase wut;gc;git rebase wut;git merge C4;go master;git rebase side;go C6;git merge C3';gb -f wut C8;go bug;git rebase wut",
|
expectTreeAsync(
|
||||||
'%7B%22branches%22%3A%7B%22master%22%3A%7B%22target%22%3A%22C7%22%2C%22id%22%3A%22master%22%7D%2C%22side%22%3A%7B%22target%22%3A%22C7%22%2C%22id%22%3A%22side%22%7D%2C%22bug%22%3A%7B%22target%22%3A%22C8%22%2C%22id%22%3A%22bug%22%7D%2C%22wut%22%3A%7B%22target%22%3A%22C8%22%2C%22id%22%3A%22wut%22%7D%7D%2C%22commits%22%3A%7B%22C0%22%3A%7B%22parents%22%3A%5B%5D%2C%22id%22%3A%22C0%22%2C%22rootCommit%22%3Atrue%7D%2C%22C1%22%3A%7B%22parents%22%3A%5B%22C0%22%5D%2C%22id%22%3A%22C1%22%7D%2C%22C2%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C2%22%7D%2C%22C3%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C3%22%7D%2C%22C4%22%3A%7B%22parents%22%3A%5B%22C2%22%2C%22C3%22%5D%2C%22id%22%3A%22C4%22%7D%2C%22C5%22%3A%7B%22parents%22%3A%5B%22C2%22%5D%2C%22id%22%3A%22C5%22%7D%2C%22C3%27%22%3A%7B%22parents%22%3A%5B%22C5%22%5D%2C%22id%22%3A%22C3%27%22%7D%2C%22C6%22%3A%7B%22parents%22%3A%5B%22C4%22%5D%2C%22id%22%3A%22C6%22%7D%2C%22C6%27%22%3A%7B%22parents%22%3A%5B%22C3%27%22%5D%2C%22id%22%3A%22C6%27%22%7D%2C%22C7%22%3A%7B%22parents%22%3A%5B%22C4%22%2C%22C6%27%22%5D%2C%22id%22%3A%22C7%22%7D%2C%22C8%22%3A%7B%22parents%22%3A%5B%22C3%27%22%2C%22C6%22%5D%2C%22id%22%3A%22C8%22%7D%7D%2C%22HEAD%22%3A%7B%22target%22%3A%22bug%22%2C%22id%22%3A%22HEAD%22%7D%7D'
|
'gc;go -b side C1;gc;git merge master;go -b bug master;gc;go -b wut C3;git rebase bug;go side;git rebase wut;gc;git rebase wut;git merge C4;go master;git rebase side;go C6;git merge C3\';gb -f wut C8;go bug;git rebase wut',
|
||||||
|
'%7B%22branches%22%3A%7B%22master%22%3A%7B%22target%22%3A%22C7%22%2C%22id%22%3A%22master%22%7D%2C%22side%22%3A%7B%22target%22%3A%22C7%22%2C%22id%22%3A%22side%22%7D%2C%22bug%22%3A%7B%22target%22%3A%22C8%22%2C%22id%22%3A%22bug%22%7D%2C%22wut%22%3A%7B%22target%22%3A%22C8%22%2C%22id%22%3A%22wut%22%7D%7D%2C%22commits%22%3A%7B%22C0%22%3A%7B%22parents%22%3A%5B%5D%2C%22id%22%3A%22C0%22%2C%22rootCommit%22%3Atrue%7D%2C%22C1%22%3A%7B%22parents%22%3A%5B%22C0%22%5D%2C%22id%22%3A%22C1%22%7D%2C%22C2%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C2%22%7D%2C%22C3%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C3%22%7D%2C%22C4%22%3A%7B%22parents%22%3A%5B%22C2%22%2C%22C3%22%5D%2C%22id%22%3A%22C4%22%7D%2C%22C5%22%3A%7B%22parents%22%3A%5B%22C2%22%5D%2C%22id%22%3A%22C5%22%7D%2C%22C3%27%22%3A%7B%22parents%22%3A%5B%22C5%22%5D%2C%22id%22%3A%22C3%27%22%7D%2C%22C6%22%3A%7B%22parents%22%3A%5B%22C4%22%5D%2C%22id%22%3A%22C6%22%7D%2C%22C6%27%22%3A%7B%22parents%22%3A%5B%22C3%27%22%5D%2C%22id%22%3A%22C6%27%22%7D%2C%22C7%22%3A%7B%22parents%22%3A%5B%22C4%22%2C%22C6%27%22%5D%2C%22id%22%3A%22C7%22%7D%2C%22C8%22%3A%7B%22parents%22%3A%5B%22C3%27%22%2C%22C6%22%5D%2C%22id%22%3A%22C8%22%7D%7D%2C%22HEAD%22%3A%7B%22target%22%3A%22bug%22%2C%22id%22%3A%22HEAD%22%7D%7D'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
var HeadlessGit = require('../src/js/git/headless').HeadlessGit;
|
|
||||||
var TreeCompare = require('../src/js/git/treeCompare').TreeCompare;
|
|
||||||
|
|
||||||
var loadTree = function(json) {
|
|
||||||
return JSON.parse(unescape(json));
|
|
||||||
};
|
|
||||||
|
|
||||||
var compareAnswer = function(headless, expectedJSON) {
|
|
||||||
var expectedTree = loadTree(expectedJSON);
|
|
||||||
var actualTree = headless.gitEngine.exportTree();
|
|
||||||
|
|
||||||
return TreeCompare.compareTrees(expectedTree, actualTree);
|
|
||||||
};
|
|
||||||
|
|
||||||
var compareAnswerExpect = function(headless, expectedJSON) {
|
|
||||||
var equal = compareAnswer(headless, expectedJSON);
|
|
||||||
if (!equal) {
|
|
||||||
var expectedTree = loadTree(expectedJSON);
|
|
||||||
var actualTree = headless.gitEngine.exportTree();
|
|
||||||
console.log('expected Tree', expectedTree);
|
|
||||||
console.log('actual Tree', actualTree);
|
|
||||||
console.log('~~~~~~~~~~~~~~~~~~~~~');
|
|
||||||
}
|
|
||||||
expect(equal).toBe(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
var expectTree = function(command, expectedJSON) {
|
|
||||||
var headless = new HeadlessGit();
|
|
||||||
headless.sendCommand(command);
|
|
||||||
compareAnswerExpect(headless, expectedJSON);
|
|
||||||
};
|
|
||||||
|
|
||||||
var expectTreeAsync = function(command, expectedJSON) {
|
|
||||||
var headless = new HeadlessGit();
|
|
||||||
runs(function() {
|
|
||||||
headless.sendCommand(command);
|
|
||||||
});
|
|
||||||
waitsFor(function() {
|
|
||||||
return compareAnswer(headless, expectedJSON);
|
|
||||||
}, 'trees should be equal', 750);
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('GitEngine', function() {
|
|
||||||
it('Rebases', function() {
|
|
||||||
expectTreeAsync(
|
|
||||||
'gc; git checkout -b side C1; gc; git rebase master',
|
|
||||||
'%7B%22branches%22%3A%7B%22master%22%3A%7B%22target%22%3A%22C2%22%2C%22id%22%3A%22master%22%7D%2C%22side%22%3A%7B%22target%22%3A%22C3%27%22%2C%22id%22%3A%22side%22%7D%7D%2C%22commits%22%3A%7B%22C0%22%3A%7B%22parents%22%3A%5B%5D%2C%22id%22%3A%22C0%22%2C%22rootCommit%22%3Atrue%7D%2C%22C1%22%3A%7B%22parents%22%3A%5B%22C0%22%5D%2C%22id%22%3A%22C1%22%7D%2C%22C2%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C2%22%7D%2C%22C3%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C3%22%7D%2C%22C3%27%22%3A%7B%22parents%22%3A%5B%22C2%22%5D%2C%22id%22%3A%22C3%27%22%7D%7D%2C%22HEAD%22%3A%7B%22target%22%3A%22side%22%2C%22id%22%3A%22HEAD%22%7D%7D'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue