diff --git a/js/historyview.js b/js/historyview.js index e350b21..6f7cd67 100644 --- a/js/historyview.js +++ b/js/historyview.js @@ -514,7 +514,7 @@ define(['d3'], function() { * @param container {String} selector for the container to render the SVG into */ render: function(container) { - var svgContainer, svg; + var svgContainer, svg, display; svgContainer = container.append('div') .classed('svg-container', true) @@ -547,6 +547,22 @@ define(['d3'], function() { .classed('current-branch-display', true) .attr('x', 10) .attr('y', 45); + + display = svg.select('text.current-branch-display'); + + display.append('svg:tspan') + .attr('x','10') + .attr('dy', '1.2em'); + display.append('svg:tspan') + .attr('x','10') + .attr('dy', '1.2em'); + display.append('svg:tspan') + .attr('x','10') + .attr('dy', '1.2em'); + display.append('svg:tspan') + .attr('x','10') + .attr('dy', '1.2em'); + } this.svgContainer = svgContainer; @@ -558,6 +574,7 @@ define(['d3'], function() { this.renderCommits(); this._setCurrentBranch(this.currentBranch); + this._setCurrentCommit(); }, destroy: function() { @@ -965,7 +982,7 @@ define(['d3'], function() { }, _setCurrentBranch: function(branch) { - var display = this.svg.select('text.current-branch-display'), + var display = this.svg.select('text.current-branch-display > tspan'), text = 'HEAD: '; if (branch && branch.indexOf('/') === -1) { @@ -975,8 +992,20 @@ define(['d3'], function() { text += ' (detached head)'; this.currentBranch = null; } + + d3.select(display[0][0]).text(text); + }, - display.text(text); + _setCurrentCommit: function() { + var display = this.svg.selectAll('text.current-branch-display > tspan'); + + //this will error out without checking first to see if commit exits, possible async issue? + if(this.getCommit('HEAD')) { + d3.select(display[0][1]).text('Sha: ' + this.getCommit('HEAD').id); + d3.select(display[0][2]).text('Parent: ' + this.getCommit('HEAD').parent); + d3.select(display[0][3]).text('Message: ' + this.getCommit('HEAD').message); + } + }, addReflogEntry: function(ref, destination, reason) { @@ -1265,7 +1294,7 @@ define(['d3'], function() { checkout: function(ref) { var commit = this.getCommit(ref); - + if (!commit) { throw new Error('Cannot find commit: ' + ref); } @@ -1279,6 +1308,7 @@ define(['d3'], function() { var isBranch = this.branches.indexOf(ref) !== -1 this._setCurrentBranch(isBranch ? ref : null); + this._setCurrentCommit(); this.moveTag('HEAD', commit.id); this.renderTags(); @@ -1479,6 +1509,7 @@ define(['d3'], function() { this.moveTag(origBranch, newHeadCommit.id) this.reset(origBranch) this._setCurrentBranch(origBranch) + this._setCurrentCommit() this.addReflogEntry( 'HEAD', targetCommit.id, 'rebase finished: returning to resf/heads/' + origBranch )