Skip to content

Commit

Permalink
Mark current branch tag
Browse files Browse the repository at this point in the history
  • Loading branch information
EmteZogaf committed Feb 16, 2017
1 parent f29b993 commit 49a258f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
8 changes: 7 additions & 1 deletion css/explaingit.css
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ span.cmd {

.control-box input[type="text"] {
position: absolute;
bottom: 0;
bottom: 0;
padding-left: 15px;
color: #FFF;
line-height: 14px;
Expand Down Expand Up @@ -228,6 +228,12 @@ g.branch-tag > rect {
stroke-width: 2;
}

g.branch-tag.current-branch > rect {
fill: #FFCC66;
stroke: #339900;
stroke-width: 2;
}

g.branch-tag.git-tag > rect {
fill: #7FC9FF;
stroke: #0026FF;
Expand Down
32 changes: 23 additions & 9 deletions js/historyview.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,14 @@ define(['d3'], function () {
break;
}

var matchedTag = function() {
var matchedTag = function() {
for (var j = 0; j < commit.tags.length; j++) {
var tag = commit.tags[j];
if (tag === ref) {
matchedCommit = commit;
return true;
}

if (tag.indexOf('[') === 0 && tag.indexOf(']') === tag.length - 1) {
tag = tag.substring(1, tag.length - 1);
}
Expand Down Expand Up @@ -360,7 +360,7 @@ define(['d3'], function () {
svgContainer = container.append('div')
.classed('svg-container', true)
.classed('remote-container', this.isRemote);

svg = svgContainer.append('svg:svg');

svg.attr('id', this.name)
Expand Down Expand Up @@ -417,7 +417,7 @@ define(['d3'], function () {
preventOverlap(commit, this);
}
},

_resizeSvg: function() {
var ele = document.getElementById(this.svg.node().id);
var container = ele.parentNode;
Expand Down Expand Up @@ -669,7 +669,8 @@ define(['d3'], function () {
renderTags: function () {
var view = this,
tagData = this._parseTagData(),
existingTags, newTags;
existingTags, newTags,
currentBranch = this.currentBranch;

existingTags = this.tagBox.selectAll('g.branch-tag')
.data(tagData, function (d) { return d.name; });
Expand Down Expand Up @@ -726,8 +727,8 @@ define(['d3'], function () {
newTags.append('svg:text')
.text(function (d) {
if (d.name.indexOf('[') === 0 && d.name.indexOf(']') === d.name.length - 1)
return d.name.substring(1, d.name.length - 1);
return d.name;
return d.name.substring(1, d.name.length - 1);
return d.name;
})
.attr('y', function (d) {
return tagY(d, view) + 14;
Expand All @@ -737,6 +738,19 @@ define(['d3'], function () {
return commit.cx;
});

this.tagBox.selectAll('g.branch-tag').attr('class', function(d) {
var classes = d3.select(this).attr('class').split(" "),
currentBranchIndex = classes.indexOf('current-branch');
if (d.name == currentBranch) {
if (currentBranchIndex < 0) {
classes.push('current-branch');
}
} else if (currentBranchIndex >= 0) {
classes.splice(currentBranchIndex, 1);
}
return classes.join(' ');
});

this._markBranchlessCommits();
},

Expand Down Expand Up @@ -969,9 +983,9 @@ define(['d3'], function () {
while (branchStartCommit.parent !== currentCommit.id) {
branchStartCommit = this.getCommit(branchStartCommit.parent);
}

branchStartCommit.isNoFFBranch = true;

this.commit({parent2: mergeTarget.id, isNoFFCommit: true});
} else if (this.isAncestor(currentCommit, mergeTarget)) {
this.fastForward(mergeTarget);
Expand Down

0 comments on commit 49a258f

Please sign in to comment.