mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-15 09:04:26 +02:00
Git Tag: Initial support for tagging
Branching in git even more useful if using tags. Simulate relase branches, maintenance branches and so on is therefore really useful in this tool. Now, rudimentary tagging is implemented, where tags can be attached to the commits, and referenced by for exmapmle git checkout Signed-off-by: Max Sikström <msikstrom@op5.com>
This commit is contained in:
parent
fa7b918be9
commit
74342e2028
13 changed files with 2009 additions and 29 deletions
|
@ -8,10 +8,13 @@ var GLOBAL = require('../util/constants').GLOBAL;
|
|||
var Collections = require('../models/collections');
|
||||
var CommitCollection = Collections.CommitCollection;
|
||||
var BranchCollection = Collections.BranchCollection;
|
||||
var TagCollection = Collections.TagCollection;
|
||||
|
||||
var VisNode = require('../visuals/visNode').VisNode;
|
||||
var VisBranch = require('../visuals/visBranch').VisBranch;
|
||||
var VisBranchCollection = require('../visuals/visBranch').VisBranchCollection;
|
||||
var VisTag = require('../visuals/visTag').VisTag;
|
||||
var VisTagCollection = require('../visuals/visTag').VisTagCollection;
|
||||
var VisEdge = require('../visuals/visEdge').VisEdge;
|
||||
var VisEdgeCollection = require('../visuals/visEdge').VisEdgeCollection;
|
||||
|
||||
|
@ -21,14 +24,17 @@ function GitVisuals(options) {
|
|||
this.visualization = options.visualization;
|
||||
this.commitCollection = options.commitCollection;
|
||||
this.branchCollection = options.branchCollection;
|
||||
this.tagCollection = options.tagCollection;
|
||||
this.visNodeMap = {};
|
||||
|
||||
this.visEdgeCollection = new VisEdgeCollection();
|
||||
this.visBranchCollection = new VisBranchCollection();
|
||||
this.visTagCollection = new VisTagCollection();
|
||||
this.commitMap = {};
|
||||
|
||||
this.rootCommit = null;
|
||||
this.branchStackMap = null;
|
||||
this.tagStackMap = null;
|
||||
this.upstreamBranchSet = null;
|
||||
this.upstreamHeadSet = null;
|
||||
|
||||
|
@ -37,6 +43,10 @@ function GitVisuals(options) {
|
|||
|
||||
this.branchCollection.on('add', this.addBranchFromEvent, this);
|
||||
this.branchCollection.on('remove', this.removeBranch, this);
|
||||
|
||||
this.tagCollection.on('add', this.addTagFromEvent, this);
|
||||
this.tagCollection.on('remove', this.removeTag, this);
|
||||
|
||||
this.deferred = [];
|
||||
|
||||
this.flipFraction = 0.65;
|
||||
|
@ -69,12 +79,18 @@ GitVisuals.prototype.resetAll = function() {
|
|||
visBranch.remove();
|
||||
}, this);
|
||||
|
||||
var tags = this.visTagCollection.toArray();
|
||||
_.each(tags, function(visTag) {
|
||||
visTag.remove();
|
||||
}, this);
|
||||
|
||||
_.each(this.visNodeMap, function(visNode) {
|
||||
visNode.remove();
|
||||
}, this);
|
||||
|
||||
this.visEdgeCollection.reset();
|
||||
this.visBranchCollection.reset();
|
||||
this.visTagsCollection.reset();
|
||||
|
||||
this.visNodeMap = {};
|
||||
this.rootCommit = null;
|
||||
|
@ -178,6 +194,7 @@ GitVisuals.prototype.animateAllAttrKeys = function(keys, attr, speed, easing) {
|
|||
|
||||
this.visBranchCollection.each(animate);
|
||||
this.visEdgeCollection.each(animate);
|
||||
this.visTagCollection.each(animate);
|
||||
_.each(this.visNodeMap, animate);
|
||||
|
||||
var time = (speed !== undefined) ? speed : GRAPHICS.defaultAnimationTime;
|
||||
|
@ -334,6 +351,7 @@ GitVisuals.prototype.animateAllFromAttrToAttr = function(fromSnapshot, toSnapsho
|
|||
|
||||
this.visBranchCollection.each(animate);
|
||||
this.visEdgeCollection.each(animate);
|
||||
this.visTagCollection.each(animate);
|
||||
_.each(this.visNodeMap, animate);
|
||||
};
|
||||
|
||||
|
@ -370,6 +388,10 @@ GitVisuals.prototype.genSnapshot = function() {
|
|||
snapshot[visEdge.getID()] = visEdge.getAttributes();
|
||||
}, this);
|
||||
|
||||
this.visTagCollection.each(function(visTag) {
|
||||
snapshot[visTag.getID()] = visTag.getAttributes();
|
||||
}, this);
|
||||
|
||||
return snapshot;
|
||||
};
|
||||
|
||||
|
@ -411,6 +433,7 @@ GitVisuals.prototype.calcTreeCoords = function() {
|
|||
|
||||
this.calcUpstreamSets();
|
||||
this.calcBranchStacks();
|
||||
this.calcTagStacks();
|
||||
|
||||
this.calcDepth();
|
||||
this.calcWidth();
|
||||
|
@ -420,6 +443,9 @@ GitVisuals.prototype.calcGraphicsCoords = function() {
|
|||
this.visBranchCollection.each(function(visBranch) {
|
||||
visBranch.updateName();
|
||||
});
|
||||
this.visTagCollection.each(function(visTag) {
|
||||
visTag.updateName();
|
||||
});
|
||||
};
|
||||
|
||||
GitVisuals.prototype.calcUpstreamSets = function() {
|
||||
|
@ -496,6 +522,23 @@ GitVisuals.prototype.calcBranchStacks = function() {
|
|||
this.branchStackMap = map;
|
||||
};
|
||||
|
||||
GitVisuals.prototype.calcTagStacks = function() {
|
||||
var tags = this.gitEngine.getTags();
|
||||
var map = {};
|
||||
_.each(tags, function(tag) {
|
||||
var thisId = tag.target.get('id');
|
||||
|
||||
map[thisId] = map[thisId] || [];
|
||||
map[thisId].push(tag);
|
||||
map[thisId].sort(function(a, b) {
|
||||
var aId = a.obj.get('id');
|
||||
var bId = b.obj.get('id');
|
||||
return aId.localeCompare(bId);
|
||||
});
|
||||
});
|
||||
this.tagStackMap = map;
|
||||
};
|
||||
|
||||
GitVisuals.prototype.calcWidth = function() {
|
||||
this.maxWidthRecursive(this.rootCommit);
|
||||
|
||||
|
@ -626,10 +669,44 @@ GitVisuals.prototype.addBranch = function(branch) {
|
|||
}
|
||||
};
|
||||
|
||||
GitVisuals.prototype.addTagFromEvent = function(tag, collection, index) {
|
||||
var action = _.bind(function() {
|
||||
this.addTag(tag);
|
||||
}, this);
|
||||
|
||||
if (!this.gitEngine || !this.gitReady) {
|
||||
this.defer(action);
|
||||
} else {
|
||||
action();
|
||||
}
|
||||
};
|
||||
|
||||
GitVisuals.prototype.addTag = function(tag) {
|
||||
var visTag = new VisTag({
|
||||
tag: tag,
|
||||
gitVisuals: this,
|
||||
gitEngine: this.gitEngine
|
||||
});
|
||||
|
||||
this.visTagCollection.add(visTag);
|
||||
if (this.gitReady) {
|
||||
visTag.genGraphics(this.paper);
|
||||
} else {
|
||||
this.defer(_.bind(function() {
|
||||
visTag.genGraphics(this.paper);
|
||||
}, this));
|
||||
}
|
||||
};
|
||||
|
||||
GitVisuals.prototype.removeVisBranch = function(visBranch) {
|
||||
this.visBranchCollection.remove(visBranch);
|
||||
};
|
||||
|
||||
GitVisuals.prototype.removeVisTag = function(visTag) {
|
||||
this.visTagCollection.remove(visTag);
|
||||
};
|
||||
|
||||
|
||||
GitVisuals.prototype.removeVisNode = function(visNode) {
|
||||
delete this.visNodeMap[visNode.getID()];
|
||||
};
|
||||
|
@ -642,6 +719,9 @@ GitVisuals.prototype.animateRefs = function(speed) {
|
|||
this.visBranchCollection.each(function(visBranch) {
|
||||
visBranch.animateUpdatedPos(speed);
|
||||
}, this);
|
||||
this.visTagCollection.each(function(visTag) {
|
||||
visTag.animateUpdatedPos(speed);
|
||||
}, this);
|
||||
};
|
||||
|
||||
GitVisuals.prototype.animateEdges = function(speed) {
|
||||
|
@ -756,6 +836,7 @@ GitVisuals.prototype.addEdge = function(idTail, idHead) {
|
|||
GitVisuals.prototype.zIndexReflow = function() {
|
||||
this.visNodesFront();
|
||||
this.visBranchesFront();
|
||||
this.visTagsFront();
|
||||
};
|
||||
|
||||
GitVisuals.prototype.visNodesFront = function() {
|
||||
|
@ -775,6 +856,17 @@ GitVisuals.prototype.visBranchesFront = function() {
|
|||
});
|
||||
};
|
||||
|
||||
GitVisuals.prototype.visTagsFront = function() {
|
||||
this.visTagCollection.each(function(vTag) {
|
||||
vTag.nonTextToFront();
|
||||
vTag.textToFront();
|
||||
});
|
||||
|
||||
this.visTagCollection.each(function(vTag) {
|
||||
vTag.textToFrontIfInStack();
|
||||
});
|
||||
};
|
||||
|
||||
GitVisuals.prototype.drawTreeFromReload = function() {
|
||||
this.gitReady = true;
|
||||
// gen all the graphics we need
|
||||
|
@ -799,6 +891,10 @@ GitVisuals.prototype.drawTreeFirstTime = function() {
|
|||
visBranch.genGraphics(this.paper);
|
||||
}, this);
|
||||
|
||||
this.visTagCollection.each(function(visTag) {
|
||||
visTag.genGraphics(this.paper);
|
||||
}, this);
|
||||
|
||||
this.zIndexReflow();
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue