mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-25 15:38:33 +02:00
awesome tree compare coverage for tests, no bugs found though
This commit is contained in:
parent
1a846bbad3
commit
6e75e04daf
7 changed files with 15 additions and 55 deletions
|
@ -6353,24 +6353,7 @@ var Level = Sandbox.extend({
|
|||
// BIG TODO REALLY REFACTOR HAX HAX
|
||||
// ok so lets see if they solved it...
|
||||
var current = this.mainVis.gitEngine.exportTree();
|
||||
var solved;
|
||||
if (this.level.compareOnlyMaster) {
|
||||
solved = TreeCompare.compareBranchWithinTrees(current, this.level.goalTreeString, 'master');
|
||||
} else if (this.level.compareOnlyBranches) {
|
||||
solved = TreeCompare.compareAllBranchesWithinTrees(current, this.level.goalTreeString);
|
||||
} else if (this.level.compareAllBranchesHashAgnostic) {
|
||||
solved = TreeCompare.compareAllBranchesWithinTreesHashAgnostic(current, this.level.goalTreeString);
|
||||
} else if (this.level.compareOnlyMasterHashAgnostic) {
|
||||
solved = TreeCompare.compareBranchesWithinTreesHashAgnostic(current, this.level.goalTreeString, ['master']);
|
||||
} else if (this.level.compareOnlyMasterHashAgnosticWithAsserts) {
|
||||
solved = TreeCompare.compareBranchesWithinTreesHashAgnostic(current, this.level.goalTreeString, ['master']);
|
||||
solved = solved && TreeCompare.evalAsserts(
|
||||
current,
|
||||
this.level.goalAsserts
|
||||
);
|
||||
} else {
|
||||
solved = TreeCompare.compareAllBranchesWithinTreesAndHEAD(current, this.level.goalTreeString);
|
||||
}
|
||||
var solved = TreeCompare.dispatch(this.level, current);
|
||||
|
||||
if (!solved) {
|
||||
defer.resolve();
|
||||
|
@ -9544,8 +9527,6 @@ TreeCompare.evalAsserts = function(tree, assertsPerBranch) {
|
|||
_.each(assertsPerBranch, function(asserts, branchName) {
|
||||
result = result && this.evalAssertsOnBranch(tree, branchName, asserts);
|
||||
}, this);
|
||||
|
||||
console.log('EVAL ASSETS was', result);
|
||||
return result;
|
||||
};
|
||||
|
||||
|
@ -9557,7 +9538,6 @@ TreeCompare.evalAssertsOnBranch = function(tree, branchName, asserts) {
|
|||
// * go to the branch given by the key
|
||||
// * traverse upwards, storing the amount of hashes on each in the data object
|
||||
// * then come back and perform functions on data
|
||||
console.log('doing asserts on', branchName);
|
||||
|
||||
if (!tree.branches[branchName]) {
|
||||
return false;
|
||||
|
@ -9568,19 +9548,17 @@ TreeCompare.evalAssertsOnBranch = function(tree, branchName, asserts) {
|
|||
var data = {};
|
||||
while (queue.length) {
|
||||
var commitRef = queue.pop();
|
||||
console.log(commitRef);
|
||||
data[this.getBaseRef(commitRef)] = this.getNumHashes(commitRef);
|
||||
|
||||
queue = queue.concat(tree.commits[commitRef].parents);
|
||||
}
|
||||
|
||||
console.log('data is', data);
|
||||
var result = true;
|
||||
_.each(asserts, function(assert) {
|
||||
try {
|
||||
result = result && assert(data);
|
||||
} catch (err) {
|
||||
console.err(err);
|
||||
console.warn('error during assert', err);
|
||||
console.log(err);
|
||||
result = false;
|
||||
}
|
||||
});
|
||||
|
@ -25102,8 +25080,6 @@ TreeCompare.evalAsserts = function(tree, assertsPerBranch) {
|
|||
_.each(assertsPerBranch, function(asserts, branchName) {
|
||||
result = result && this.evalAssertsOnBranch(tree, branchName, asserts);
|
||||
}, this);
|
||||
|
||||
console.log('EVAL ASSETS was', result);
|
||||
return result;
|
||||
};
|
||||
|
||||
|
@ -25115,7 +25091,6 @@ TreeCompare.evalAssertsOnBranch = function(tree, branchName, asserts) {
|
|||
// * go to the branch given by the key
|
||||
// * traverse upwards, storing the amount of hashes on each in the data object
|
||||
// * then come back and perform functions on data
|
||||
console.log('doing asserts on', branchName);
|
||||
|
||||
if (!tree.branches[branchName]) {
|
||||
return false;
|
||||
|
@ -25126,19 +25101,17 @@ TreeCompare.evalAssertsOnBranch = function(tree, branchName, asserts) {
|
|||
var data = {};
|
||||
while (queue.length) {
|
||||
var commitRef = queue.pop();
|
||||
console.log(commitRef);
|
||||
data[this.getBaseRef(commitRef)] = this.getNumHashes(commitRef);
|
||||
|
||||
queue = queue.concat(tree.commits[commitRef].parents);
|
||||
}
|
||||
|
||||
console.log('data is', data);
|
||||
var result = true;
|
||||
_.each(asserts, function(assert) {
|
||||
try {
|
||||
result = result && assert(data);
|
||||
} catch (err) {
|
||||
console.err(err);
|
||||
console.warn('error during assert', err);
|
||||
console.log(err);
|
||||
result = false;
|
||||
}
|
||||
});
|
||||
|
@ -26847,24 +26820,7 @@ var Level = Sandbox.extend({
|
|||
// BIG TODO REALLY REFACTOR HAX HAX
|
||||
// ok so lets see if they solved it...
|
||||
var current = this.mainVis.gitEngine.exportTree();
|
||||
var solved;
|
||||
if (this.level.compareOnlyMaster) {
|
||||
solved = TreeCompare.compareBranchWithinTrees(current, this.level.goalTreeString, 'master');
|
||||
} else if (this.level.compareOnlyBranches) {
|
||||
solved = TreeCompare.compareAllBranchesWithinTrees(current, this.level.goalTreeString);
|
||||
} else if (this.level.compareAllBranchesHashAgnostic) {
|
||||
solved = TreeCompare.compareAllBranchesWithinTreesHashAgnostic(current, this.level.goalTreeString);
|
||||
} else if (this.level.compareOnlyMasterHashAgnostic) {
|
||||
solved = TreeCompare.compareBranchesWithinTreesHashAgnostic(current, this.level.goalTreeString, ['master']);
|
||||
} else if (this.level.compareOnlyMasterHashAgnosticWithAsserts) {
|
||||
solved = TreeCompare.compareBranchesWithinTreesHashAgnostic(current, this.level.goalTreeString, ['master']);
|
||||
solved = solved && TreeCompare.evalAsserts(
|
||||
current,
|
||||
this.level.goalAsserts
|
||||
);
|
||||
} else {
|
||||
solved = TreeCompare.compareAllBranchesWithinTreesAndHEAD(current, this.level.goalTreeString);
|
||||
}
|
||||
var solved = TreeCompare.dispatch(this.level, current);
|
||||
|
||||
if (!solved) {
|
||||
defer.resolve();
|
||||
|
|
1
build/bundle.min.565ccc81.js
Normal file
1
build/bundle.min.565ccc81.js
Normal file
File diff suppressed because one or more lines are too long
1
build/bundle.min.js
vendored
Normal file
1
build/bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -426,7 +426,7 @@
|
|||
For a much easier time perusing the source, see the individual files at:
|
||||
https://github.com/pcottle/learnGitBranching
|
||||
-->
|
||||
<script src="build/bundle.js"></script>
|
||||
<script src="build/bundle.min.565ccc81.js"></script>
|
||||
|
||||
<!-- 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
|
||||
|
|
|
@ -45,7 +45,7 @@ describe('Tree Compare', function() {
|
|||
"{\"branches\":{\"master\":{\"target\":\"C3\",\"id\":\"master\"}},\"commits\":{\"C0\":{\"parents\":[],\"id\":\"C0\",\"rootCommit\":true},\"C1\":{\"parents\":[\"C0\"],\"id\":\"C1\"},\"C2\":{\"parents\":[\"C1\"],\"id\":\"C2\"},\"C3\":{\"parents\":[\"C2\"],\"id\":\"C3\"}},\"HEAD\":{\"target\":\"master\",\"id\":\"HEAD\"}}",
|
||||
{
|
||||
// side branch that is checked out
|
||||
'{"branches":{"master":{"target":"C3","id":"master"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"},"C3":{"parents":["C2"],"id":"C3"}},"HEAD":{"target":"C2","id":"HEAD"}}': true,
|
||||
'{"branches":{"master":{"target":"C3","id":"master"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"},"C3":{"parents":["C2"],"id":"C3"}},"HEAD":{"target":"master","id":"HEAD"}}': true,
|
||||
// head detached
|
||||
'{"branches":{"master":{"target":"C3","id":"master"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"},"C3":{"parents":["C2"],"id":"C3"}},"HEAD":{"target":"C2","id":"HEAD"}}': true
|
||||
}
|
||||
|
|
|
@ -9,7 +9,9 @@ TreeCompare.dispatchFromLevel = function(levelBlob, treeToCompare) {
|
|||
};
|
||||
|
||||
TreeCompare.dispatch = function(levelBlob, goalTreeString, treeToCompare) {
|
||||
switch(true) {
|
||||
var getAroundLintTrue = true;
|
||||
// i actually prefer this to else if
|
||||
switch (getAroundLintTrue) {
|
||||
case !!levelBlob.compareOnlyMaster:
|
||||
return TreeCompare.compareBranchWithinTrees(treeToCompare, goalTreeString, 'master');
|
||||
case !!levelBlob.compareOnlyBranches:
|
||||
|
@ -151,7 +153,6 @@ TreeCompare.evalAssertsOnBranch = function(tree, branchName, asserts) {
|
|||
while (queue.length) {
|
||||
var commitRef = queue.pop();
|
||||
data[this.getBaseRef(commitRef)] = this.getNumHashes(commitRef);
|
||||
|
||||
queue = queue.concat(tree.commits[commitRef].parents);
|
||||
}
|
||||
|
||||
|
|
3
todo.txt
3
todo.txt
|
@ -17,7 +17,6 @@ Origin things:
|
|||
[ ] tree comparison with origin.... sigh
|
||||
[ ] prototype visual layout (background change + header? maybe...)
|
||||
[ ] git pull animation
|
||||
[ ] why is rebase -i broken?
|
||||
|
||||
Medium things:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -40,6 +39,8 @@ Ideas for cleaning
|
|||
Done things:
|
||||
(I only started this on Dec 17th 2012 to get a better sense of what was done)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
[x] why is rebase -i broken? dont emulate touch events
|
||||
[x] tree compare test coverage
|
||||
[x] remote branch it is tracking (points to a remote branch model)
|
||||
[x] fix branch -a and branch -r to: show remote branches or all branches
|
||||
[x] fix branch -f to not allow moving remote branches?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue