Skip to content

Commit 1631f8d

Browse files
committed
Mark current branch tag
1 parent f29b993 commit 1631f8d

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

css/explaingit.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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; });
@@ -707,6 +708,9 @@ define(['d3'], function () {
707708
} else if (d.name.toUpperCase() === 'HEAD') {
708709
classes += ' head-tag';
709710
}
711+
if (d.name == currentBranch) {
712+
classes += " current-branch"
713+
}
710714
return classes;
711715
});
712716

@@ -737,6 +741,19 @@ define(['d3'], function () {
737741
return commit.cx;
738742
});
739743

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

0 commit comments

Comments
 (0)