mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-24 06:58:34 +02:00
Resolves #164 case insensitive branch comparison with test and validation
This commit is contained in:
parent
0be3577572
commit
43579378e8
5 changed files with 47 additions and 8 deletions
|
@ -80,7 +80,7 @@ TreeCompare.compareAllBranchesWithinTreesAndHEAD = function(treeA, treeB) {
|
|||
treeB = this.convertTreeSafe(treeB);
|
||||
|
||||
// also compare tags!! for just one level
|
||||
return treeA.HEAD.target == treeB.HEAD.target &&
|
||||
return treeA.HEAD.target === treeB.HEAD.target &&
|
||||
this.compareAllBranchesWithinTrees(treeA, treeB) &&
|
||||
this.compareAllTagsWithinTrees(treeA, treeB);
|
||||
};
|
||||
|
@ -319,9 +319,31 @@ TreeCompare.getRecurseCompare = function(treeA, treeB, options) {
|
|||
return recurseCompare;
|
||||
};
|
||||
|
||||
TreeCompare.lowercaseTree = function(tree) {
|
||||
if (tree.HEAD) {
|
||||
tree.HEAD.target = tree.HEAD.target.toLocaleLowerCase();
|
||||
}
|
||||
|
||||
var branches = tree.branches;
|
||||
tree.branches = {};
|
||||
_.each(branches, function(obj, name) {
|
||||
obj.id = obj.id.toLocaleLowerCase();
|
||||
tree.branches[name.toLocaleLowerCase()] = obj;
|
||||
});
|
||||
return tree;
|
||||
};
|
||||
|
||||
TreeCompare.convertTreeSafe = function(tree) {
|
||||
if (typeof tree == 'string') {
|
||||
return JSON.parse(unescape(tree));
|
||||
if (typeof tree !== 'string') {
|
||||
return tree;
|
||||
}
|
||||
tree = JSON.parse(unescape(tree));
|
||||
// ok we are almost done -- but we need to case insensitive
|
||||
// certain fields. so go ahead and do that.
|
||||
// handle HEAD target first
|
||||
this.lowercaseTree(tree);
|
||||
if (tree.originTree) {
|
||||
tree.originTree = this.lowercaseTree(tree.originTree);
|
||||
}
|
||||
return tree;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue