Skip to content

Commit

Permalink
change(rule-commit-messages): add "test:" to the default list of allo…
Browse files Browse the repository at this point in the history
…wed types
  • Loading branch information
tomassebestik committed Dec 15, 2023
1 parent e18f632 commit 02d4a9d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion src/configParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions tests/ruleCommitMessages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}));
Expand All @@ -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();
Expand Down

0 comments on commit 02d4a9d

Please sign in to comment.