mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 08:28:50 +02:00
Resolves #146 not taking into account tags when comparing
This commit is contained in:
parent
8d23d92456
commit
2866be53aa
2 changed files with 20 additions and 2 deletions
|
@ -79,7 +79,10 @@ TreeCompare.compareAllBranchesWithinTreesAndHEAD = function(treeA, treeB) {
|
|||
treeA = this.convertTreeSafe(treeA);
|
||||
treeB = this.convertTreeSafe(treeB);
|
||||
|
||||
return treeA.HEAD.target == treeB.HEAD.target && this.compareAllBranchesWithinTrees(treeA, treeB);
|
||||
// also compare tags!! for just one level
|
||||
return treeA.HEAD.target == treeB.HEAD.target &&
|
||||
this.compareAllBranchesWithinTrees(treeA, treeB) &&
|
||||
this.compareAllTagsWithinTrees(treeA, treeB);
|
||||
};
|
||||
|
||||
TreeCompare.compareAllBranchesWithinTrees = function(treeA, treeB) {
|
||||
|
@ -99,6 +102,14 @@ TreeCompare.compareAllBranchesWithinTrees = function(treeA, treeB) {
|
|||
return result;
|
||||
};
|
||||
|
||||
TreeCompare.compareAllTagsWithinTrees = function(treeA, treeB) {
|
||||
treeA = this.convertTreeSafe(treeA);
|
||||
treeB = this.convertTreeSafe(treeB);
|
||||
this.reduceTreeFields([treeA, treeB]);
|
||||
|
||||
return _.isEqual(treeA.tags, treeB.tags);
|
||||
};
|
||||
|
||||
TreeCompare.compareBranchesWithinTrees = function(treeA, treeB, branches) {
|
||||
var result = true;
|
||||
_.each(branches, function(branchName) {
|
||||
|
@ -321,12 +332,17 @@ TreeCompare.reduceTreeFields = function(trees) {
|
|||
'id',
|
||||
'rootCommit'
|
||||
];
|
||||
var commitSortFields = ['children', 'parents'];
|
||||
var branchSaveFields = [
|
||||
'target',
|
||||
'id',
|
||||
'remoteTrackingBranchID'
|
||||
];
|
||||
var tagSaveFields = [
|
||||
'target',
|
||||
'id'
|
||||
];
|
||||
|
||||
var commitSortFields = ['children', 'parents'];
|
||||
// for backwards compatibility, fill in some fields if missing
|
||||
var defaults = {
|
||||
remoteTrackingBranchID: null
|
||||
|
@ -372,6 +388,7 @@ TreeCompare.reduceTreeFields = function(trees) {
|
|||
_.each(trees, function(tree) {
|
||||
saveOnly(tree, 'commits', commitSaveFields, commitSortFields);
|
||||
saveOnly(tree, 'branches', branchSaveFields);
|
||||
saveOnly(tree, 'tags', tagSaveFields);
|
||||
|
||||
tree.HEAD = {
|
||||
target: tree.HEAD.target,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue