Page MenuHomePhabricator

Gerrit commit message body wrapped near 80 characters instead 100
Open, LowPublic

Description

An example from https://gerrit.wikimedia.org/r/c/mediawiki/extensions/ContentTranslation/+/608014/1:

In this commit message, the longest line is 84 characters. Which is with in the limits of 100 characters as doumented at https://www.mediawiki.org/wiki/Gerrit/Commit_message_guidelines#Body

As we can see, the lines are wrapped unnecessary and makes the reading difficult

Expected result:

Commit message body wrapped only at 100 characters or above

Event Timeline

santhosh created this task.Jun 29 2020, 5:19 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 29 2020, 5:19 AM
hashar triaged this task as Low priority.Jun 29 2020, 11:00 AM
hashar added a subscriber: hashar.

The example at the top of the guide has the longest line at 65 characters. It used to state More details, wrap lines around 76 characters. (diff).

Gerrit uses some CSS magic to find the size of the box:

polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_html.js
.commitMessage {
...
  /* Account for border and padding and rounding errors. */
  max-width: calc(72ch + 2px + 2 * var(--spacing-m) + 0.4px);
}

#commitMessageEditor {
  min-width: calc(72ch + 2px + 2 * var(--spacing-m) + 0.4px)
}

It used to be min-width: 72ch;.

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/ContentTranslation/+/607030

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/ContentTranslation/+/608014/1

Our commit message validator code (integration/commit-message-validator) enforces 80 characters or less for the first line and accepts up to 100 characters in the body. I guess based on the wiki article.

commit_message_validator/validators/GlobalMessageValidator.py
def check_line(self, lineno):
    line = self._lines[lineno]

    # First line <=80
    if lineno == 0 and len(line) > 80:
        if not RE_REVERT_SUBJECT.match(line):
            yield "First line should be <=80 characters"

    # No line >100 characters (unless it is only a URL)
    elif len(line) > 100 and not RE_URL.match(line):
        yield "Line should be <=100 characters"