Repository navigation
Commit summary truncation - #2575
Conversation
| * string | ||
| */ | ||
| function trimTrailingWhitespace(value: string) { | ||
| return value.replace(/\s+$/, '') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| if (summary.length > maxSummaryLength) { | ||
| // Truncate at least 3 characters off the end to avoid just an ellipsis | ||
| // followed by 1-2 characters in the body. This matches dotcom behavior. | ||
| const truncateLength = maxSummaryLength - 3 |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Truncation looks good to me here. I'm not too worried about URL's being truncated in the middle since I don't think URL's appear in the commit summary often. |
| if (summary.length > maxSummaryLength) { | ||
| // Truncate at least 3 characters off the end to avoid just an ellipsis | ||
| // followed by 1-2 characters in the body. This matches dotcom behavior. | ||
| const truncateLength = maxSummaryLength - 3 |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| interface ICommitSummaryState { | ||
| /** | ||
| * The commit message summary, i.e. the first line | ||
| * in the commit message. Note that this |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
🌞 |
|
Looks like some legit prettier complaints. |
|
Travis is on fire so I'm not gonna wait around for it. |
This fixes #1742 by truncating and wrapping commit summaries over 72 characters in the same manner that dotcom currently does it. We're able to render 72 (non-fancy-unicodey) characters in the minimum window width and even if we didn't it'd just wrap like it currently does.
This follows what @donokuda and I talked about and is a fairly simple fix we think will work alright for now. Note that this might cause links to break if we truncate them in the middle. The solution for this would be to do a pre-pass with the tokenizer and truncate using tokens instead but that's a bigger task that I'm not convinced that we need right now.
Before
After