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

Add the ability to put some text in the commit bubble. (commitDotText) #196

Merged
merged 3 commits into from
Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ var commitConfig = {
dotStrokeWidth: 10,
messageHashDisplay: false,
messageAuthorDisplay: true,
messageShort: "C1",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think messageShort is explicit enough for people without context.

What do you think about something like commitDotText? Something else?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea. I'll update.

message: "Alors c'est qui le papa ?",
tooltipDisplay: false,
author: "Me <me@planee.fr>"
Expand Down Expand Up @@ -128,7 +129,8 @@ test.merge(master, "My special merge commit message");

// Then, continue committing on the "test" branch
test.commit({
message: "It works !"
message: "It works !",
messageShort: "C2"
});

var fastForwardBranch = test.branch("fast-forward");
Expand Down
17 changes: 16 additions & 1 deletion src/gitgraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,7 @@
* @param {number[]} [options.lineDash = this.template.commit.dot.lineDash]
*
* @param {string} [options.message = "He doesn't like George Michael! Boooo!"] - Commit message
* @param {string} [options.message] - short commit message (A few chars) to appear on the commit dot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad copy/past here, this should be [options.messageShort] 😉

* @param {string} [options.messageColor = options.color] - Specific message color
* @param {string} [options.messageFont = this.template.commit.message.font] - Font of the message
* @param {boolean} [options.messageDisplay = this.template.commit.message.display] - Commit message display policy
Expand Down Expand Up @@ -1085,7 +1086,8 @@
this.date = options.date || new Date().toUTCString();
this.detail = options.detail || null;
this.sha1 = options.sha1 || (Math.random(100)).toString(16).substring(3, 10);
this.message = options.message || "He doesn't like George Michael! Boooo!";
this.message = options.message || options.messageShort || "He doesn't like George Michael! Boooo!";
this.messageShort = options.messageShort;
this.arrowDisplay = options.arrowDisplay;
this.messageDisplay = _booleanOptionOr(options.messageDisplay, this.template.commit.message.display);
this.messageAuthorDisplay = _booleanOptionOr(options.messageAuthorDisplay, this.template.commit.message.displayAuthor);
Expand Down Expand Up @@ -1205,6 +1207,19 @@
}
}

if (this.messageShort !== undefined) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can write if (this.messageShort) here, to be consistant with the actual code style.

var previousTextBaseline = this.context.textBaseline;
var previousTextAlign = this.context.textAlign;

this.context.fillStyle = "#000";
this.context.textAlign = "center";
this.context.textBaseline = 'middle';
this.context.fillText(this.messageShort, this.x, this.y);

this.context.textBaseline = previousTextBaseline;
this.context.textAlign = previousTextAlign;
}

// Message
if (this.messageDisplay) {
var message = this.message;
Expand Down