Presubmit.Rules.Message (presubmit v0.2.2)

Copy Markdown View Source

Commit message conventions. All of these skip for change sets without a message.

Subjects git writes itself — Revert "…" and Merge … — are exempt from the shape rules (subject, subject_length, body_line_length, scope); override with exempt: (a list of regexes, [] to exempt nothing). no_fixup applies to committed revisions only: fixup!/squash! commits are meant to exist locally and be autosquashed before they reach main. The other rules skip those commits altogether, as every rule does (Presubmit.Rule): a fixup! [tag] text subject is not the one that lands.

Options:

  • subject: — regex the subject must match (rule :subject; skipped without it).
  • max_subject_length: — default 72 characters, counted as graphemes (rule :subject_length). Many policies make it a warning: warn: [:subject_length].
  • max_body_line_length: — default 72 characters, counted as graphemes (rule :body_line_length). Trailers are not measured, nor are body lines that wrapping could not bring within the limit: lines that start with whitespace (code, output) or > (quotes), Key: value lines with a one-word value, and lines whose last word (a URL, a path) is longer than the limit on its own. See Presubmit.Assertions.assert_body_line_length/2.
  • scope: — {regex_with_capture, (scope -> path_pattern)}; the subject's scope must agree with the paths touched (rule :scope; skipped without it).
  • trailers: — list of {trigger, key, value_regex | nil}; when trigger (a function of the commit) is true, the trailer must be present (rule :trailers; skipped without it).

  • exempt: — subjects the shape rules skip; default [~r/^Revert "/, ~r/^Merge /].

Rules

  • no_fixup — no fixup!/squash!/amend! commits (only on :head/:rev)
  • subject_length — subject fits the configured length
  • body_line_length — body lines fit the configured length
  • subject — subject matches the configured pattern
  • scope — subject scope matches the paths touched
  • trailers — required trailers are present