mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-26 16:08:34 +02:00
better tree comparsion from Issue #28
This commit is contained in:
parent
2a96052002
commit
bf6432b286
9 changed files with 84 additions and 36 deletions
|
@ -6949,6 +6949,7 @@ var Level = Sandbox.extend({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO refactor this ugly ass switch statement...
|
||||||
// ok so lets see if they solved it...
|
// ok so lets see if they solved it...
|
||||||
var current = this.mainVis.gitEngine.exportTree();
|
var current = this.mainVis.gitEngine.exportTree();
|
||||||
var solved;
|
var solved;
|
||||||
|
@ -6956,6 +6957,10 @@ var Level = Sandbox.extend({
|
||||||
solved = this.treeCompare.compareBranchWithinTrees(current, this.level.goalTreeString, 'master');
|
solved = this.treeCompare.compareBranchWithinTrees(current, this.level.goalTreeString, 'master');
|
||||||
} else if (this.level.compareOnlyBranches) {
|
} else if (this.level.compareOnlyBranches) {
|
||||||
solved = this.treeCompare.compareAllBranchesWithinTrees(current, this.level.goalTreeString);
|
solved = this.treeCompare.compareAllBranchesWithinTrees(current, this.level.goalTreeString);
|
||||||
|
} else if (this.level.compareAllBranchesHashAgnostic) {
|
||||||
|
solved = this.treeCompare.compareAllBranchesWithinTreesHashAgnostic(current, this.level.goalTreeString);
|
||||||
|
} else if (this.level.compareOnlyMasterHashAgnostic) {
|
||||||
|
solved = this.treeCompare.compareBranchesWithinTreesHashAgnostic(current, this.level.goalTreeString, ['master']);
|
||||||
} else {
|
} else {
|
||||||
solved = this.treeCompare.compareAllBranchesWithinTreesAndHEAD(current, this.level.goalTreeString);
|
solved = this.treeCompare.compareAllBranchesWithinTreesAndHEAD(current, this.level.goalTreeString);
|
||||||
}
|
}
|
||||||
|
@ -9640,6 +9645,23 @@ TreeCompare.prototype.compareBranchWithinTrees = function(treeA, treeB, branchNa
|
||||||
};
|
};
|
||||||
|
|
||||||
TreeCompare.prototype.compareAllBranchesWithinTreesHashAgnostic = function(treeA, treeB) {
|
TreeCompare.prototype.compareAllBranchesWithinTreesHashAgnostic = function(treeA, treeB) {
|
||||||
|
treeA = this.convertTreeSafe(treeA);
|
||||||
|
treeB = this.convertTreeSafe(treeB);
|
||||||
|
this.reduceTreeFields([treeA, treeB]);
|
||||||
|
|
||||||
|
var allBranches = _.extend(
|
||||||
|
{},
|
||||||
|
treeA.branches,
|
||||||
|
treeB.branches
|
||||||
|
);
|
||||||
|
var branchNames = [];
|
||||||
|
_.each(allBranches, function(obj, name) { branchNames.push(name); });
|
||||||
|
console.log(branchNames);
|
||||||
|
|
||||||
|
return this.compareBranchesWithinTreesHashAgnostic(treeA, treeB, branchNames);
|
||||||
|
};
|
||||||
|
|
||||||
|
TreeCompare.prototype.compareBranchesWithinTreesHashAgnostic = function(treeA, treeB, branches) {
|
||||||
// we can't DRY unfortunately here because we need a special _.isEqual function
|
// we can't DRY unfortunately here because we need a special _.isEqual function
|
||||||
// for both the recursive compare and the branch compare
|
// for both the recursive compare and the branch compare
|
||||||
treeA = this.convertTreeSafe(treeA);
|
treeA = this.convertTreeSafe(treeA);
|
||||||
|
@ -9659,16 +9681,10 @@ TreeCompare.prototype.compareAllBranchesWithinTreesHashAgnostic = function(treeA
|
||||||
// and a function to compare recursively without worrying about hashes
|
// and a function to compare recursively without worrying about hashes
|
||||||
var recurseCompare = this.getRecurseCompareHashAgnostic(treeA, treeB);
|
var recurseCompare = this.getRecurseCompareHashAgnostic(treeA, treeB);
|
||||||
|
|
||||||
var allBranches = _.extend(
|
|
||||||
{},
|
|
||||||
treeA.branches,
|
|
||||||
treeB.branches
|
|
||||||
);
|
|
||||||
|
|
||||||
var result = true;
|
var result = true;
|
||||||
_.each(allBranches, function(branchObj, branchName) {
|
_.each(branches, function(branchName) {
|
||||||
branchA = treeA.branches[branchName];
|
var branchA = treeA.branches[branchName];
|
||||||
branchB = treeB.branches[branchName];
|
var branchB = treeB.branches[branchName];
|
||||||
|
|
||||||
result = result && compareBranchObjs(branchA, branchB) &&
|
result = result && compareBranchObjs(branchA, branchB) &&
|
||||||
recurseCompare(treeA.commits[branchA.target], treeB.commits[branchB.target]);
|
recurseCompare(treeA.commits[branchA.target], treeB.commits[branchB.target]);
|
||||||
|
@ -17450,7 +17466,7 @@ require.define("/src/levels/intro/5.js",function(require,module,exports,__dirnam
|
||||||
});
|
});
|
||||||
|
|
||||||
require.define("/src/levels/rebase/1.js",function(require,module,exports,__dirname,__filename,process,global){exports.level = {
|
require.define("/src/levels/rebase/1.js",function(require,module,exports,__dirname,__filename,process,global){exports.level = {
|
||||||
"compareOnlyMaster": true,
|
"compareOnlyMasterHashAgnostic": true,
|
||||||
"disabledMap" : {
|
"disabledMap" : {
|
||||||
"git revert": true
|
"git revert": true
|
||||||
},
|
},
|
||||||
|
@ -17482,7 +17498,7 @@ require.define("/src/levels/rebase/1.js",function(require,module,exports,__dirna
|
||||||
});
|
});
|
||||||
|
|
||||||
require.define("/src/levels/rebase/2.js",function(require,module,exports,__dirname,__filename,process,global){exports.level = {
|
require.define("/src/levels/rebase/2.js",function(require,module,exports,__dirname,__filename,process,global){exports.level = {
|
||||||
"compareOnlyBranches": true,
|
"compareAllBranchesHashAgnostic": true,
|
||||||
"disabledMap" : {
|
"disabledMap" : {
|
||||||
"git revert": true
|
"git revert": true
|
||||||
},
|
},
|
||||||
|
@ -20994,6 +21010,23 @@ TreeCompare.prototype.compareBranchWithinTrees = function(treeA, treeB, branchNa
|
||||||
};
|
};
|
||||||
|
|
||||||
TreeCompare.prototype.compareAllBranchesWithinTreesHashAgnostic = function(treeA, treeB) {
|
TreeCompare.prototype.compareAllBranchesWithinTreesHashAgnostic = function(treeA, treeB) {
|
||||||
|
treeA = this.convertTreeSafe(treeA);
|
||||||
|
treeB = this.convertTreeSafe(treeB);
|
||||||
|
this.reduceTreeFields([treeA, treeB]);
|
||||||
|
|
||||||
|
var allBranches = _.extend(
|
||||||
|
{},
|
||||||
|
treeA.branches,
|
||||||
|
treeB.branches
|
||||||
|
);
|
||||||
|
var branchNames = [];
|
||||||
|
_.each(allBranches, function(obj, name) { branchNames.push(name); });
|
||||||
|
console.log(branchNames);
|
||||||
|
|
||||||
|
return this.compareBranchesWithinTreesHashAgnostic(treeA, treeB, branchNames);
|
||||||
|
};
|
||||||
|
|
||||||
|
TreeCompare.prototype.compareBranchesWithinTreesHashAgnostic = function(treeA, treeB, branches) {
|
||||||
// we can't DRY unfortunately here because we need a special _.isEqual function
|
// we can't DRY unfortunately here because we need a special _.isEqual function
|
||||||
// for both the recursive compare and the branch compare
|
// for both the recursive compare and the branch compare
|
||||||
treeA = this.convertTreeSafe(treeA);
|
treeA = this.convertTreeSafe(treeA);
|
||||||
|
@ -21013,16 +21046,10 @@ TreeCompare.prototype.compareAllBranchesWithinTreesHashAgnostic = function(treeA
|
||||||
// and a function to compare recursively without worrying about hashes
|
// and a function to compare recursively without worrying about hashes
|
||||||
var recurseCompare = this.getRecurseCompareHashAgnostic(treeA, treeB);
|
var recurseCompare = this.getRecurseCompareHashAgnostic(treeA, treeB);
|
||||||
|
|
||||||
var allBranches = _.extend(
|
|
||||||
{},
|
|
||||||
treeA.branches,
|
|
||||||
treeB.branches
|
|
||||||
);
|
|
||||||
|
|
||||||
var result = true;
|
var result = true;
|
||||||
_.each(allBranches, function(branchObj, branchName) {
|
_.each(branches, function(branchName) {
|
||||||
branchA = treeA.branches[branchName];
|
var branchA = treeA.branches[branchName];
|
||||||
branchB = treeB.branches[branchName];
|
var branchB = treeB.branches[branchName];
|
||||||
|
|
||||||
result = result && compareBranchObjs(branchA, branchB) &&
|
result = result && compareBranchObjs(branchA, branchB) &&
|
||||||
recurseCompare(treeA.commits[branchA.target], treeB.commits[branchB.target]);
|
recurseCompare(treeA.commits[branchA.target], treeB.commits[branchB.target]);
|
||||||
|
@ -22034,6 +22061,7 @@ var Level = Sandbox.extend({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO refactor this ugly ass switch statement...
|
||||||
// ok so lets see if they solved it...
|
// ok so lets see if they solved it...
|
||||||
var current = this.mainVis.gitEngine.exportTree();
|
var current = this.mainVis.gitEngine.exportTree();
|
||||||
var solved;
|
var solved;
|
||||||
|
@ -22041,6 +22069,10 @@ var Level = Sandbox.extend({
|
||||||
solved = this.treeCompare.compareBranchWithinTrees(current, this.level.goalTreeString, 'master');
|
solved = this.treeCompare.compareBranchWithinTrees(current, this.level.goalTreeString, 'master');
|
||||||
} else if (this.level.compareOnlyBranches) {
|
} else if (this.level.compareOnlyBranches) {
|
||||||
solved = this.treeCompare.compareAllBranchesWithinTrees(current, this.level.goalTreeString);
|
solved = this.treeCompare.compareAllBranchesWithinTrees(current, this.level.goalTreeString);
|
||||||
|
} else if (this.level.compareAllBranchesHashAgnostic) {
|
||||||
|
solved = this.treeCompare.compareAllBranchesWithinTreesHashAgnostic(current, this.level.goalTreeString);
|
||||||
|
} else if (this.level.compareOnlyMasterHashAgnostic) {
|
||||||
|
solved = this.treeCompare.compareBranchesWithinTreesHashAgnostic(current, this.level.goalTreeString, ['master']);
|
||||||
} else {
|
} else {
|
||||||
solved = this.treeCompare.compareAllBranchesWithinTreesAndHEAD(current, this.level.goalTreeString);
|
solved = this.treeCompare.compareAllBranchesWithinTreesAndHEAD(current, this.level.goalTreeString);
|
||||||
}
|
}
|
||||||
|
@ -29087,7 +29119,7 @@ require.define("/src/levels/mixed/3.js",function(require,module,exports,__dirnam
|
||||||
require("/src/levels/mixed/3.js");
|
require("/src/levels/mixed/3.js");
|
||||||
|
|
||||||
require.define("/src/levels/rebase/1.js",function(require,module,exports,__dirname,__filename,process,global){exports.level = {
|
require.define("/src/levels/rebase/1.js",function(require,module,exports,__dirname,__filename,process,global){exports.level = {
|
||||||
"compareOnlyMaster": true,
|
"compareOnlyMasterHashAgnostic": true,
|
||||||
"disabledMap" : {
|
"disabledMap" : {
|
||||||
"git revert": true
|
"git revert": true
|
||||||
},
|
},
|
||||||
|
@ -29120,7 +29152,7 @@ require.define("/src/levels/rebase/1.js",function(require,module,exports,__dirna
|
||||||
require("/src/levels/rebase/1.js");
|
require("/src/levels/rebase/1.js");
|
||||||
|
|
||||||
require.define("/src/levels/rebase/2.js",function(require,module,exports,__dirname,__filename,process,global){exports.level = {
|
require.define("/src/levels/rebase/2.js",function(require,module,exports,__dirname,__filename,process,global){exports.level = {
|
||||||
"compareOnlyBranches": true,
|
"compareAllBranchesHashAgnostic": true,
|
||||||
"disabledMap" : {
|
"disabledMap" : {
|
||||||
"git revert": true
|
"git revert": true
|
||||||
},
|
},
|
||||||
|
|
1
build/bundle.min.09842c9c.js
Normal file
1
build/bundle.min.09842c9c.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
|
@ -409,7 +409,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.7e188d82.js"></script>
|
<script src="build/bundle.min.09842c9c.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
|
||||||
|
|
|
@ -52,6 +52,23 @@ TreeCompare.prototype.compareBranchWithinTrees = function(treeA, treeB, branchNa
|
||||||
};
|
};
|
||||||
|
|
||||||
TreeCompare.prototype.compareAllBranchesWithinTreesHashAgnostic = function(treeA, treeB) {
|
TreeCompare.prototype.compareAllBranchesWithinTreesHashAgnostic = function(treeA, treeB) {
|
||||||
|
treeA = this.convertTreeSafe(treeA);
|
||||||
|
treeB = this.convertTreeSafe(treeB);
|
||||||
|
this.reduceTreeFields([treeA, treeB]);
|
||||||
|
|
||||||
|
var allBranches = _.extend(
|
||||||
|
{},
|
||||||
|
treeA.branches,
|
||||||
|
treeB.branches
|
||||||
|
);
|
||||||
|
var branchNames = [];
|
||||||
|
_.each(allBranches, function(obj, name) { branchNames.push(name); });
|
||||||
|
console.log(branchNames);
|
||||||
|
|
||||||
|
return this.compareBranchesWithinTreesHashAgnostic(treeA, treeB, branchNames);
|
||||||
|
};
|
||||||
|
|
||||||
|
TreeCompare.prototype.compareBranchesWithinTreesHashAgnostic = function(treeA, treeB, branches) {
|
||||||
// we can't DRY unfortunately here because we need a special _.isEqual function
|
// we can't DRY unfortunately here because we need a special _.isEqual function
|
||||||
// for both the recursive compare and the branch compare
|
// for both the recursive compare and the branch compare
|
||||||
treeA = this.convertTreeSafe(treeA);
|
treeA = this.convertTreeSafe(treeA);
|
||||||
|
@ -71,16 +88,10 @@ TreeCompare.prototype.compareAllBranchesWithinTreesHashAgnostic = function(treeA
|
||||||
// and a function to compare recursively without worrying about hashes
|
// and a function to compare recursively without worrying about hashes
|
||||||
var recurseCompare = this.getRecurseCompareHashAgnostic(treeA, treeB);
|
var recurseCompare = this.getRecurseCompareHashAgnostic(treeA, treeB);
|
||||||
|
|
||||||
var allBranches = _.extend(
|
|
||||||
{},
|
|
||||||
treeA.branches,
|
|
||||||
treeB.branches
|
|
||||||
);
|
|
||||||
|
|
||||||
var result = true;
|
var result = true;
|
||||||
_.each(allBranches, function(branchObj, branchName) {
|
_.each(branches, function(branchName) {
|
||||||
branchA = treeA.branches[branchName];
|
var branchA = treeA.branches[branchName];
|
||||||
branchB = treeB.branches[branchName];
|
var branchB = treeB.branches[branchName];
|
||||||
|
|
||||||
result = result && compareBranchObjs(branchA, branchB) &&
|
result = result && compareBranchObjs(branchA, branchB) &&
|
||||||
recurseCompare(treeA.commits[branchA.target], treeB.commits[branchB.target]);
|
recurseCompare(treeA.commits[branchA.target], treeB.commits[branchB.target]);
|
||||||
|
|
|
@ -289,6 +289,7 @@ var Level = Sandbox.extend({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO refactor this ugly ass switch statement...
|
||||||
// ok so lets see if they solved it...
|
// ok so lets see if they solved it...
|
||||||
var current = this.mainVis.gitEngine.exportTree();
|
var current = this.mainVis.gitEngine.exportTree();
|
||||||
var solved;
|
var solved;
|
||||||
|
@ -296,6 +297,10 @@ var Level = Sandbox.extend({
|
||||||
solved = this.treeCompare.compareBranchWithinTrees(current, this.level.goalTreeString, 'master');
|
solved = this.treeCompare.compareBranchWithinTrees(current, this.level.goalTreeString, 'master');
|
||||||
} else if (this.level.compareOnlyBranches) {
|
} else if (this.level.compareOnlyBranches) {
|
||||||
solved = this.treeCompare.compareAllBranchesWithinTrees(current, this.level.goalTreeString);
|
solved = this.treeCompare.compareAllBranchesWithinTrees(current, this.level.goalTreeString);
|
||||||
|
} else if (this.level.compareAllBranchesHashAgnostic) {
|
||||||
|
solved = this.treeCompare.compareAllBranchesWithinTreesHashAgnostic(current, this.level.goalTreeString);
|
||||||
|
} else if (this.level.compareOnlyMasterHashAgnostic) {
|
||||||
|
solved = this.treeCompare.compareBranchesWithinTreesHashAgnostic(current, this.level.goalTreeString, ['master']);
|
||||||
} else {
|
} else {
|
||||||
solved = this.treeCompare.compareAllBranchesWithinTreesAndHEAD(current, this.level.goalTreeString);
|
solved = this.treeCompare.compareAllBranchesWithinTreesAndHEAD(current, this.level.goalTreeString);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
exports.level = {
|
exports.level = {
|
||||||
"compareOnlyMaster": true,
|
"compareOnlyMasterHashAgnostic": true,
|
||||||
"disabledMap" : {
|
"disabledMap" : {
|
||||||
"git revert": true
|
"git revert": true
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
exports.level = {
|
exports.level = {
|
||||||
"compareOnlyBranches": true,
|
"compareAllBranchesHashAgnostic": true,
|
||||||
"disabledMap" : {
|
"disabledMap" : {
|
||||||
"git revert": true
|
"git revert": true
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue