mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 08:50:06 +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);
|
treeA = this.convertTreeSafe(treeA);
|
||||||
treeB = this.convertTreeSafe(treeB);
|
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) {
|
TreeCompare.compareAllBranchesWithinTrees = function(treeA, treeB) {
|
||||||
|
@ -99,6 +102,14 @@ TreeCompare.compareAllBranchesWithinTrees = function(treeA, treeB) {
|
||||||
return result;
|
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) {
|
TreeCompare.compareBranchesWithinTrees = function(treeA, treeB, branches) {
|
||||||
var result = true;
|
var result = true;
|
||||||
_.each(branches, function(branchName) {
|
_.each(branches, function(branchName) {
|
||||||
|
@ -321,12 +332,17 @@ TreeCompare.reduceTreeFields = function(trees) {
|
||||||
'id',
|
'id',
|
||||||
'rootCommit'
|
'rootCommit'
|
||||||
];
|
];
|
||||||
var commitSortFields = ['children', 'parents'];
|
|
||||||
var branchSaveFields = [
|
var branchSaveFields = [
|
||||||
'target',
|
'target',
|
||||||
'id',
|
'id',
|
||||||
'remoteTrackingBranchID'
|
'remoteTrackingBranchID'
|
||||||
];
|
];
|
||||||
|
var tagSaveFields = [
|
||||||
|
'target',
|
||||||
|
'id'
|
||||||
|
];
|
||||||
|
|
||||||
|
var commitSortFields = ['children', 'parents'];
|
||||||
// for backwards compatibility, fill in some fields if missing
|
// for backwards compatibility, fill in some fields if missing
|
||||||
var defaults = {
|
var defaults = {
|
||||||
remoteTrackingBranchID: null
|
remoteTrackingBranchID: null
|
||||||
|
@ -372,6 +388,7 @@ TreeCompare.reduceTreeFields = function(trees) {
|
||||||
_.each(trees, function(tree) {
|
_.each(trees, function(tree) {
|
||||||
saveOnly(tree, 'commits', commitSaveFields, commitSortFields);
|
saveOnly(tree, 'commits', commitSaveFields, commitSortFields);
|
||||||
saveOnly(tree, 'branches', branchSaveFields);
|
saveOnly(tree, 'branches', branchSaveFields);
|
||||||
|
saveOnly(tree, 'tags', tagSaveFields);
|
||||||
|
|
||||||
tree.HEAD = {
|
tree.HEAD = {
|
||||||
target: tree.HEAD.target,
|
target: tree.HEAD.target,
|
||||||
|
|
|
@ -19,6 +19,7 @@ var toGlobalize = {
|
||||||
MultiView: require('../views/multiView'),
|
MultiView: require('../views/multiView'),
|
||||||
ZoomLevel: require('../util/zoomLevel'),
|
ZoomLevel: require('../util/zoomLevel'),
|
||||||
VisBranch: require('../visuals/visBranch'),
|
VisBranch: require('../visuals/visBranch'),
|
||||||
|
TreeCompare: require('../graph/treeCompare'),
|
||||||
Level: require('../level'),
|
Level: require('../level'),
|
||||||
Sandbox: require('../sandbox/'),
|
Sandbox: require('../sandbox/'),
|
||||||
GitDemonstrationView: require('../views/gitDemonstrationView'),
|
GitDemonstrationView: require('../views/gitDemonstrationView'),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue