Skip to content

Commit 43f5937

Browse files
committed
Mark current branch tag
1 parent f29b993 commit 43f5937

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

css/explaingit.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ span.cmd {
134134

135135
.control-box input[type="text"] {
136136
position: absolute;
137-
bottom: 0;
137+
bottom: 0;
138138
padding-left: 15px;
139139
color: #FFF;
140140
line-height: 14px;
@@ -228,6 +228,12 @@ g.branch-tag > rect {
228228
stroke-width: 2;
229229
}
230230

231+
g.branch-tag.current-branch > rect {
232+
fill: #FFCC66;
233+
stroke: #339900;
234+
stroke-width: 2;
235+
}
236+
231237
g.branch-tag.git-tag > rect {
232238
fill: #7FC9FF;
233239
stroke: #0026FF;

js/historyview.js

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,14 @@ define(['d3'], function () {
293293
break;
294294
}
295295

296-
var matchedTag = function() {
296+
var matchedTag = function() {
297297
for (var j = 0; j < commit.tags.length; j++) {
298298
var tag = commit.tags[j];
299299
if (tag === ref) {
300300
matchedCommit = commit;
301301
return true;
302302
}
303-
303+
304304
if (tag.indexOf('[') === 0 && tag.indexOf(']') === tag.length - 1) {
305305
tag = tag.substring(1, tag.length - 1);
306306
}
@@ -360,7 +360,7 @@ define(['d3'], function () {
360360
svgContainer = container.append('div')
361361
.classed('svg-container', true)
362362
.classed('remote-container', this.isRemote);
363-
363+
364364
svg = svgContainer.append('svg:svg');
365365

366366
svg.attr('id', this.name)
@@ -417,7 +417,7 @@ define(['d3'], function () {
417417
preventOverlap(commit, this);
418418
}
419419
},
420-
420+
421421
_resizeSvg: function() {
422422
var ele = document.getElementById(this.svg.node().id);
423423
var container = ele.parentNode;
@@ -669,7 +669,8 @@ define(['d3'], function () {
669669
renderTags: function () {
670670
var view = this,
671671
tagData = this._parseTagData(),
672-
existingTags, newTags;
672+
existingTags, newTags,
673+
currentBranch = this.currentBranch;
673674

674675
existingTags = this.tagBox.selectAll('g.branch-tag')
675676
.data(tagData, function (d) { return d.name; });
@@ -726,8 +727,8 @@ define(['d3'], function () {
726727
newTags.append('svg:text')
727728
.text(function (d) {
728729
if (d.name.indexOf('[') === 0 && d.name.indexOf(']') === d.name.length - 1)
729-
return d.name.substring(1, d.name.length - 1);
730-
return d.name;
730+
return d.name.substring(1, d.name.length - 1);
731+
return d.name;
731732
})
732733
.attr('y', function (d) {
733734
return tagY(d, view) + 14;
@@ -737,6 +738,19 @@ define(['d3'], function () {
737738
return commit.cx;
738739
});
739740

741+
this.tagBox.selectAll('g.branch-tag').attr('class', function(d) {
742+
var cls = d3.select(this).attr('class').split(" "),
743+
currentBranchIndex = cls.indexOf('current-branch');
744+
if (d.name == currentBranch) {
745+
if (currentBranchIndex < 0) {
746+
cls.push('current-branch');
747+
}
748+
} else if (currentBranchIndex >= 0) {
749+
cls.splice(currentBranchIndex, 1);
750+
}
751+
return cls.join(' ');
752+
});
753+
740754
this._markBranchlessCommits();
741755
},
742756

@@ -969,9 +983,9 @@ define(['d3'], function () {
969983
while (branchStartCommit.parent !== currentCommit.id) {
970984
branchStartCommit = this.getCommit(branchStartCommit.parent);
971985
}
972-
986+
973987
branchStartCommit.isNoFFBranch = true;
974-
988+
975989
this.commit({parent2: mergeTarget.id, isNoFFCommit: true});
976990
} else if (this.isAncestor(currentCommit, mergeTarget)) {
977991
this.fastForward(mergeTarget);

0 commit comments

Comments
 (0)