Skip to content

Improve commit linting when commit squashing is enabled

Adrien Kohlbecker requested to merge ak/danger-lint-squash into master

What does this MR do?

When commit squashing is enabled on a merge request, only the first multiline commit is relevant. Indeed, according to https://docs.gitlab.com/ee/user/project/merge_requests/squash_and_merge.html:

The squashed commit’s commit message will be either:

- Taken from the first multi-line commit message in the merge.
- The merge request’s title if no multi-line commit message is found.

In that case, there is no need to enforce commit standards on any other commit. This will save time and prevent pipelines from failing unnecessarily. Non exhaustive examples of linters not relevant for squashed commits:

  • The commit subject must start with a capital letter
  • The commit subject must not end with a period
  • Commits that change 30 or more lines across at least three files must describe these changes in the commit body
  • The commit subject must contain at least three words

This MR changes the linting to only happen on the first multiline commit if it exists.

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Performance and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Merge request reports