Skip to content
This repository was archived by the owner on Jul 13, 2024. It is now read-only.

Commit bf7a583

Browse files
authored
Merge pull request #196 from carlorivera/develop
Add the ability to put some text in the commit bubble. (commitDotText)
2 parents a720871 + 07d7f7f commit bf7a583

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

examples/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ var commitConfig = {
7777
dotStrokeWidth: 10,
7878
messageHashDisplay: false,
7979
messageAuthorDisplay: true,
80+
commitDotText: "C1",
8081
message: "Alors c'est qui le papa ?",
8182
tooltipDisplay: false,
8283
author: "Me <me@planee.fr>"
@@ -128,7 +129,8 @@ test.merge(master, "My special merge commit message");
128129

129130
// Then, continue committing on the "test" branch
130131
test.commit({
131-
message: "It works !"
132+
message: "It works !",
133+
commitDotText: "C2"
132134
});
133135

134136
var fastForwardBranch = test.branch("fast-forward");

src/gitgraph.js

+16
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,7 @@
10531053
* @param {number[]} [options.lineDash = this.template.commit.dot.lineDash]
10541054
*
10551055
* @param {string} [options.message = "He doesn't like George Michael! Boooo!"] - Commit message
1056+
* @param {string} [options.commitDotText] - short commit message (A few chars) to appear on the commit dot
10561057
* @param {string} [options.messageColor = options.color] - Specific message color
10571058
* @param {string} [options.messageFont = this.template.commit.message.font] - Font of the message
10581059
* @param {boolean} [options.messageDisplay = this.template.commit.message.display] - Commit message display policy
@@ -1086,6 +1087,7 @@
10861087
this.detail = options.detail || null;
10871088
this.sha1 = options.sha1 || (Math.random(100)).toString(16).substring(3, 10);
10881089
this.message = options.message || "He doesn't like George Michael! Boooo!";
1090+
this.commitDotText = options.commitDotText;
10891091
this.arrowDisplay = options.arrowDisplay;
10901092
this.messageDisplay = _booleanOptionOr(options.messageDisplay, this.template.commit.message.display);
10911093
this.messageAuthorDisplay = _booleanOptionOr(options.messageAuthorDisplay, this.template.commit.message.displayAuthor);
@@ -1205,6 +1207,20 @@
12051207
}
12061208
}
12071209

1210+
// Commit Dot Text
1211+
if (this.commitDotText) {
1212+
var previousTextBaseline = this.context.textBaseline;
1213+
var previousTextAlign = this.context.textAlign;
1214+
1215+
this.context.fillStyle = "#000";
1216+
this.context.textAlign = "center";
1217+
this.context.textBaseline = 'middle';
1218+
this.context.fillText(this.commitDotText, this.x, this.y);
1219+
1220+
this.context.textBaseline = previousTextBaseline;
1221+
this.context.textAlign = previousTextAlign;
1222+
}
1223+
12081224
// Message
12091225
if (this.messageDisplay) {
12101226
var message = this.message;

0 commit comments

Comments
 (0)