Remove enforcement of capitalized first word after Conventional Commit prefix

What does this MR do?

Changes the capital-letter check in BaseLinter (subject_starts_with_lowercase?):

  • If a commit subject or merge request title starts with a prefix, the first word after the prefix can be lowercase.
  • If there is no prefix, the subject must still start with a capital letter.

A prefix is a Conventional Commit type (for example fix: or feat(scope):) or a square-bracket tag (for example [ci skip]). PREFIX_REGEX is the same pattern that the old check used inline.

Why is this change being made?

Conventional Commits workflows usually use lowercase after the type (for example fix: resolve null pointer). Danger reported these subjects as "The commit subject must start with a capital letter".

The check stays for subjects without a prefix. This is less disruptive for projects that use the gem, such as gitlab-org/gitlab, where the commit message guidelines require a capital letter.

MergeRequestLinter inherits from BaseLinter, so the change also applies to merge request titles.

Examples

Subject Before After
fix: resolve null pointer Problem No problem
[ci skip] a commit message Problem No problem
api: Add a thing No problem No problem
add a new feature Problem Problem
[ci skip]a commit message Problem Problem

Changes

  • Added PREFIX_REGEX to BaseLinter and used it in subject_starts_with_lowercase?.
  • Updated spec/gitlab/dangerfiles/base_linter_spec.rb with Conventional Commit examples and lowercase-after-prefix cases.
  • Added a Changelog: changed trailer to the commit.
  • Verified locally: all RSpec specs and RuboCop checks pass.

Closes #91 (closed)

Edited by Michael Kozono

Merge request reports

Loading
Loading