From 02d4a9d94f33adb9f6e33f9f757505d64daf97b2 Mon Sep 17 00:00:00 2001 From: Tomas Sebestik Date: Fri, 15 Dec 2023 11:55:36 +0100 Subject: [PATCH] change(rule-commit-messages): add "test:" to the default list of allowed types --- .pre-commit-config.yaml | 3 +++ README.md | 34 ++++++++++++++++---------------- src/configParameters.ts | 2 +- tests/ruleCommitMessages.test.ts | 12 +++++------ 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 19f2646..afdc2c6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,8 @@ --- +minimum_pre_commit_version: 3.3.0 default_install_hook_types: [pre-commit, commit-msg] +default_stages: [pre-commit] + repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 diff --git a/README.md b/README.md index 7d79381..a5ff60b 100644 --- a/README.md +++ b/README.md @@ -91,23 +91,23 @@ If your project has specific needs, Shared GitHub DangerJS can be configured to **Here is complete list of configurable parameters:** -| Parameter | CI Variable | Type | Default value | -| ------------------------------------------------------ | -------------------------------------- | ---- | -------------------------------------------------- | -| Enable rule PR Description | `rule-description` | str | `"true"` (use `"false"` to disable this rule) | -| Enable rule PR Lint Commit Messages | `rule-commit-messages` | str | `"true"` (use `"false"` to disable this rule) | -| Enable rule PR Size (changed lines) | `rule-size-lines` | str | `"true"` (use `"false"` to disable this rule) | -| Enable rule PR Source branch name | `rule-source-branch` | str | `"true"` (use `"false"` to disable this rule) | -| Enable rule PR Target branch name | `rule-target-branch` | str | `"true"` (use `"false"` to disable this rule) | -| Enable rule PR Too Many Commits | `rule-max-commits` | str | `"true"` (use `"false"` to disable this check) | -| Commit message allowed "Type"s | `commit-messages-types` | str | `"change,ci,docs,feat,fix,refactor,remove,revert"` | -| Commit message maximum length "Body" line | `commit-messages-max-body-line-length` | str | `"100"` | -| Commit message maximum length "Summary" | `commit-messages-max-summary-length` | str | `"72"` | -| Commit message minimum length "Summary" | `commit-messages-min-summary-length` | str | `"20"` | -| Ignore sections of PR description when counting length | `description-ignore-sections` | str | `"related,release,breaking"` | -| Maximum changed code lines in PR | `max-size-lines` | str | `"1000"` | -| Maximum commits in PR (soft limit, throw `info`) | `max-commits-info` | str | `"2"` | -| Maximum commits in PR (hard limit, throw `warn`) | `max-commits-warn` | str | `"5"` | -| Minimum length of PR description | `description-min-length` | str | `"50"` | +| Parameter | CI Variable | Type | Default value | +| ------------------------------------------------------ | -------------------------------------- | ---- | ------------------------------------------------------- | +| Enable rule PR Description | `rule-description` | str | `"true"` (use `"false"` to disable this rule) | +| Enable rule PR Lint Commit Messages | `rule-commit-messages` | str | `"true"` (use `"false"` to disable this rule) | +| Enable rule PR Size (changed lines) | `rule-size-lines` | str | `"true"` (use `"false"` to disable this rule) | +| Enable rule PR Source branch name | `rule-source-branch` | str | `"true"` (use `"false"` to disable this rule) | +| Enable rule PR Target branch name | `rule-target-branch` | str | `"true"` (use `"false"` to disable this rule) | +| Enable rule PR Too Many Commits | `rule-max-commits` | str | `"true"` (use `"false"` to disable this check) | +| Commit message allowed "Type"s | `commit-messages-types` | str | `"change,ci,docs,feat,fix,refactor,remove,revert,test"` | +| Commit message maximum length "Body" line | `commit-messages-max-body-line-length` | str | `"100"` | +| Commit message maximum length "Summary" | `commit-messages-max-summary-length` | str | `"72"` | +| Commit message minimum length "Summary" | `commit-messages-min-summary-length` | str | `"20"` | +| Ignore sections of PR description when counting length | `description-ignore-sections` | str | `"related,release,breaking"` | +| Maximum changed code lines in PR | `max-size-lines` | str | `"1000"` | +| Maximum commits in PR (soft limit, throw `info`) | `max-commits-info` | str | `"2"` | +| Maximum commits in PR (hard limit, throw `warn`) | `max-commits-warn` | str | `"5"` | +| Minimum length of PR description | `description-min-length` | str | `"50"` | These values can be defined in your project `DangerJS Pull Request linter` workflow, for example like this: diff --git a/src/configParameters.ts b/src/configParameters.ts index a5aa0ed..293f4f4 100644 --- a/src/configParameters.ts +++ b/src/configParameters.ts @@ -15,7 +15,7 @@ const defaults = { prDescription: { enabled: true, minLength: 50, ignoredSections: 'related,release,breaking' }, commitMessages: { enabled: true, - allowedTypes: 'change,ci,docs,feat,fix,refactor,remove,revert', + allowedTypes: 'change,ci,docs,feat,fix,refactor,remove,revert,test', minSummaryLength: 20, maxSummaryLength: 72, maxBodyLineLength: 100, diff --git a/tests/ruleCommitMessages.test.ts b/tests/ruleCommitMessages.test.ts index 5437422..0135778 100644 --- a/tests/ruleCommitMessages.test.ts +++ b/tests/ruleCommitMessages.test.ts @@ -26,12 +26,6 @@ describe('TESTS: Commit messages style', () => { jest.doMock('../src/configParameters', () => ({ config: { ...originalConfig, - commitMessages: { - maxBodyLineLength: 100, - maxSummaryLength: 72, - minSummaryLength: 20, - allowedTypes: 'change,ci,docs,feat,fix,refactor,remove,revert', - }, }, recordRuleExitStatus, })); @@ -44,6 +38,12 @@ describe('TESTS: Commit messages style', () => { expect(warn).not.toHaveBeenCalled(); }); + it('EXPECT PASS: Message with "scope" and "body", type "test"', async () => { + danger.git.commits = [{ message: 'test(bootloader): This is commit message with scope and body\n\nThis is a text of body' }]; + await ruleCommitMessages(); + expect(warn).not.toHaveBeenCalled(); + }); + it('EXPECT PASS: Message with "scope", without "body"', async () => { danger.git.commits = [{ message: 'change(wifi): This is commit message with scope without body' }]; await ruleCommitMessages();