mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-24 23:18:35 +02:00
WOOHOOOOOOO assertion engine complete. Issue #28 this is crazy
This commit is contained in:
parent
e4b82fd653
commit
f9cdc32fcb
5 changed files with 51 additions and 1096 deletions
|
@ -103,12 +103,13 @@ TreeCompare.prototype.compareBranchesWithinTreesHashAgnostic = function(treeA, t
|
|||
};
|
||||
|
||||
TreeCompare.prototype.evalAsserts = function(tree, assertsPerBranch) {
|
||||
|
||||
var result = true;
|
||||
_.each(assertsPerBranch, function(asserts, branchName) {
|
||||
result = result && this.evalAssertsOnBranch(tree, branchName, asserts);
|
||||
}, this);
|
||||
return true;
|
||||
|
||||
console.log('EVAL ASSETS was', result);
|
||||
return result;
|
||||
};
|
||||
|
||||
TreeCompare.prototype.evalAssertsOnBranch = function(tree, branchName, asserts) {
|
||||
|
@ -125,10 +126,12 @@ TreeCompare.prototype.evalAssertsOnBranch = function(tree, branchName, asserts)
|
|||
return false;
|
||||
}
|
||||
|
||||
var queue = [branchName.target];
|
||||
var branch = tree.branches[branchName];
|
||||
var queue = [branch.target];
|
||||
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);
|
||||
|
@ -187,11 +190,15 @@ TreeCompare.prototype.getRecurseCompareHashAgnostic = function(treeA, treeB) {
|
|||
|
||||
// some buildup functions
|
||||
var getStrippedCommitCopy = _.bind(function(commit) {
|
||||
if (!commit) { return {}; }
|
||||
return _.extend(
|
||||
{},
|
||||
commit,
|
||||
{id: this.getBaseRef(commit.id)
|
||||
});
|
||||
{
|
||||
id: this.getBaseRef(commit.id),
|
||||
parents: null
|
||||
}
|
||||
);
|
||||
}, this);
|
||||
|
||||
var isEqual = function(commitA, commitB) {
|
||||
|
@ -218,8 +225,9 @@ TreeCompare.prototype.getRecurseCompare = function(treeA, treeB, options) {
|
|||
// we loop through each parent ID. we sort the parent ID's beforehand
|
||||
// so the index lookup is valid. for merge commits this will duplicate some of the
|
||||
// checking (because we aren't doing graph search) but it's not a huge deal
|
||||
var allParents = _.unique(commitA.parents.concat(commitB.parents));
|
||||
_.each(allParents, function(pAid, index) {
|
||||
var maxNumParents = Math.max(commitA.parents.length, commitB.parents.length);
|
||||
_.each(_.range(maxNumParents), function(index) {
|
||||
var pAid = commitA.parents[index];
|
||||
var pBid = commitB.parents[index];
|
||||
|
||||
// if treeA or treeB doesn't have this parent,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue