mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 00:18:56 +02:00
got tags making commits not faded out or orphaned anymore
This commit is contained in:
parent
e9e2cda241
commit
9fbe654cb2
3 changed files with 37 additions and 22 deletions
|
@ -1747,6 +1747,14 @@ GitEngine.prototype.pruneTree = function() {
|
|||
};
|
||||
|
||||
GitEngine.prototype.getUpstreamBranchSet = function() {
|
||||
return this.getUpstreamCollectionSet(this.branchCollection);
|
||||
};
|
||||
|
||||
GitEngine.prototype.getUpstreamTagSet = function() {
|
||||
return this.getUpstreamCollectionSet(this.tagCollection);
|
||||
};
|
||||
|
||||
GitEngine.prototype.getUpstreamCollectionSet = function(collection) {
|
||||
// this is expensive!! so only call once in a while
|
||||
var commitToSet = {};
|
||||
|
||||
|
@ -1775,16 +1783,16 @@ GitEngine.prototype.getUpstreamBranchSet = function() {
|
|||
return set;
|
||||
};
|
||||
|
||||
this.branchCollection.each(function(branch) {
|
||||
var set = bfsSearch(branch.get('target'));
|
||||
collection.each(function(ref) {
|
||||
var set = bfsSearch(ref.get('target'));
|
||||
_.each(set, function(id) {
|
||||
commitToSet[id] = commitToSet[id] || [];
|
||||
|
||||
// only add it if it's not there, so hue blending is ok
|
||||
if (!inArray(commitToSet[id], branch.get('id'))) {
|
||||
if (!inArray(commitToSet[id], ref.get('id'))) {
|
||||
commitToSet[id].push({
|
||||
obj: branch,
|
||||
id: branch.get('id')
|
||||
obj: ref,
|
||||
id: ref.get('id')
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -36,6 +36,7 @@ function GitVisuals(options) {
|
|||
this.branchStackMap = null;
|
||||
this.tagStackMap = null;
|
||||
this.upstreamBranchSet = null;
|
||||
this.upstreamTagSet = null;
|
||||
this.upstreamHeadSet = null;
|
||||
|
||||
this.paper = options.paper;
|
||||
|
@ -451,6 +452,7 @@ GitVisuals.prototype.calcGraphicsCoords = function() {
|
|||
GitVisuals.prototype.calcUpstreamSets = function() {
|
||||
this.upstreamBranchSet = this.gitEngine.getUpstreamBranchSet();
|
||||
this.upstreamHeadSet = this.gitEngine.getUpstreamHeadSet();
|
||||
this.upstreamTagSet = this.gitEngine.getUpstreamTagSet();
|
||||
};
|
||||
|
||||
GitVisuals.prototype.getCommitUpstreamBranches = function(commit) {
|
||||
|
@ -492,9 +494,12 @@ GitVisuals.prototype.getCommitUpstreamStatus = function(commit) {
|
|||
var id = commit.get('id');
|
||||
var branch = this.upstreamBranchSet;
|
||||
var head = this.upstreamHeadSet;
|
||||
var tag = this.upstreamTagSet;
|
||||
|
||||
if (branch[id]) {
|
||||
return 'branch';
|
||||
} else if (tag[id]) {
|
||||
return 'tag';
|
||||
} else if (head[id]) {
|
||||
return 'head';
|
||||
} else {
|
||||
|
@ -502,6 +507,23 @@ GitVisuals.prototype.getCommitUpstreamStatus = function(commit) {
|
|||
}
|
||||
};
|
||||
|
||||
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.calcBranchStacks = function() {
|
||||
var branches = this.gitEngine.getBranches();
|
||||
var map = {};
|
||||
|
@ -522,23 +544,6 @@ 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);
|
||||
|
||||
|
|
|
@ -318,6 +318,8 @@ var VisNode = VisBase.extend({
|
|||
var stat = this.gitVisuals.getCommitUpstreamStatus(this.get('commit'));
|
||||
if (stat == 'head') {
|
||||
return GRAPHICS.headRectFill;
|
||||
} else if (stat == 'tag') {
|
||||
return GRAPHICS.orphanNodeFill;
|
||||
} else if (stat == 'none') {
|
||||
return GRAPHICS.orphanNodeFill;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue