Skip to content

Commit summary truncation - #2575

Merged
joshaber merged 16 commits into
masterfrom
summary-truncation
Sep 8, 2017
Merged

joshaber merged 16 commits into
masterfrom
summary-truncation

Conversation

@niik

@niik niik commented Aug 29, 2017

Copy link
Copy Markdown
Member

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

image

After

image

@niik niik added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Aug 29, 2017
* string
*/
function trimTrailingWhitespace(value: string) {
return value.replace(/\s+$/, '')

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Comment thread app/src/ui/history/commit-summary.tsx Outdated
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.

This comment was marked as spam.

@iAmWillShepherd iAmWillShepherd self-assigned this Aug 31, 2017
@donokuda

donokuda commented Sep 1, 2017

Copy link
Copy Markdown
Contributor

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.

@joshaber joshaber added this to the 1.0: The Last Milestone milestone Sep 7, 2017

@joshaber joshaber left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just a couple nits.

Comment thread app/src/ui/history/commit-summary.tsx Outdated
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.

Comment thread app/src/ui/history/commit-summary.tsx Outdated
interface ICommitSummaryState {
/**
* The commit message summary, i.e. the first line
* in the commit message. Note that this

This comment was marked as spam.

@niik

niik commented Sep 8, 2017

Copy link
Copy Markdown
Member Author

🌞

@joshaber

joshaber commented Sep 8, 2017

Copy link
Copy Markdown
Contributor

Looks like some legit prettier complaints.

@joshaber

joshaber commented Sep 8, 2017

Copy link
Copy Markdown
Contributor

Travis is on fire so I'm not gonna wait around for it.

@joshaber
joshaber merged commit 13c16bd into master Sep 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants