Skip to content

Commit

Permalink
Merge pull request onlywei#36 from Sfeir/master
Browse files Browse the repository at this point in the history
Adding -m option to git commit
  • Loading branch information
onlywei committed Aug 14, 2015
2 parents 16931b5 + 1ffc853 commit 7762dd4
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 17 deletions.
8 changes: 8 additions & 0 deletions css/explaingit.css
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,18 @@ circle.commit.branchless {
text.id-label {
text-anchor: middle;
font-family: Courier New;
font-weight: bolder;
fill: #666;
font-size: 10px;
}

text.message-label {
text-anchor: middle;
font-family: Courier New;
fill: #666;
font-size: 10px;
}

g.branch-tag > rect {
fill: #FFCC66;
stroke: #CC9900;
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ <h2>Specific Examples</h2>
name: 'Zen',
height: '100%',
commitData: [
{id: 'e137e9b', tags: ['master']}
{id: 'e137e9b', tags: ['master'], message: 'first commit'}
],
initialMessage:
'Have fun.'
Expand Down
18 changes: 16 additions & 2 deletions js/controlbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,22 @@ define(['d3'], function () {
this._scrollToBottom();
},

commit: function () {
this.historyView.commit();
commit: function (args) {
if (args.length >= 2) {
var arg = args.shift();

switch (arg) {
case '-m':
var message = args.join(" ");
this.historyView.commit({},message);
break;
default:
this.historyView.commit();
break;
}
} else {
this.historyView.commit();
}
},

branch: function (args) {
Expand Down
38 changes: 24 additions & 14 deletions js/historyview.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ define(['d3'], function () {
});
};

fixIdPosition = function (selection, view) {
fixIdPosition = function (selection, view, delta) {
selection.attr('x', function (d) {
return d.cx;
}).attr('y', function (d) {
return d.cy + view.commitRadius + 14;
return d.cy + view.commitRadius + delta;
});
};

Expand All @@ -215,7 +215,7 @@ define(['d3'], function () {
if (commitCY < (view.baseLine)) {
return commitCY - 45 - (tagIndex * 25);
} else {
return commitCY + 40 + (tagIndex * 25);
return commitCY + 50 + (tagIndex * 25);
}
};

Expand Down Expand Up @@ -578,21 +578,26 @@ define(['d3'], function () {
},

_renderIdLabels: function () {
this._renderText('id-label', function (d) { return d.id + '..'; }, 14);
this._renderText('message-label', function (d) { return d.message; }, 24);
},

_renderText: function(className, getText, delta) {
var view = this,
existingLabels,
newLabels;
existingTexts,
newtexts;

existingLabels = this.commitBox.selectAll('text.id-label')
existingTexts = this.commitBox.selectAll('text.' + className)
.data(this.commitData, function (d) { return d.id; })
.text(function (d) { return d.id + '..'; });
.text(getText);

existingLabels.transition().call(fixIdPosition, view);
existingTexts.transition().call(fixIdPosition, view, delta);

newLabels = existingLabels.enter()
newtexts = existingTexts.enter()
.insert('svg:text', ':first-child')
.classed('id-label', true)
.text(function (d) { return d.id + '..'; })
.call(fixIdPosition, view);
.classed(className, true)
.text(getText)
.call(fixIdPosition, view, delta);
},

_parseTagData: function () {
Expand Down Expand Up @@ -802,12 +807,13 @@ define(['d3'], function () {
return inTree;
},

commit: function (commit) {
commit: function (commit, message) {
commit = commit || {};

!commit.id && (commit.id = HistoryView.generateId());
!commit.tags && (commit.tags = []);

commit.message = message;
if (!commit.parent) {
if (!this.currentBranch) {
throw new Error('Not a good idea to make commits while in a detached HEAD state.');
Expand Down Expand Up @@ -980,6 +986,7 @@ define(['d3'], function () {
currentCommit = this.getCommit('HEAD'),
isCommonAncestor,
rebaseTreeLoc,
rebaseMessage,
toRebase = [], rebasedCommit,
remainingHusk;

Expand All @@ -1000,7 +1007,7 @@ define(['d3'], function () {
return 'Fast-Forward';
}

rebaseTreeLoc = rebaseTarget.id
rebaseTreeLoc = rebaseTarget.id;

while (!isCommonAncestor) {
toRebase.unshift(currentCommit);
Expand All @@ -1010,10 +1017,12 @@ define(['d3'], function () {

for (var i = 0; i < toRebase.length; i++) {
rebasedCommit = toRebase[i];
rebaseMessage = rebasedCommit.message;

remainingHusk = {
id: rebasedCommit.id,
parent: rebasedCommit.parent,
message: rebasedCommit.message,
tags: []
};

Expand All @@ -1029,6 +1038,7 @@ define(['d3'], function () {
rebasedCommit.parent = rebaseTreeLoc;
rebaseTreeLoc = HistoryView.generateId()
rebasedCommit.id = rebaseTreeLoc;
rebasedCommit.message = rebaseMessage;
rebasedCommit.tags.length = 0;
rebasedCommit.rebased = true;
}
Expand Down

0 comments on commit 7762dd4

Please sign in to comment.