You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48-20Lines changed: 48 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -10,77 +10,103 @@
10
10
The Conventional Precommit Linter is a tool designed to ensure commit messages follow the Conventional Commits standard, enhancing the readability and traceability of your project's history.
The _conventional-precommit-linter hook_ runs every time you execute the `git commit` command (when you want to commit your changes). Since this hook operates in the `commit-msg` stage, simply running a pre-commit check without actually committing (using `pre-commit run`), will have no effect, and this hook will be ignored.
27
+
28
+
The same applies to running pre-commit hooks in CI (Continuous Integration) job environments - **this hook is simply skipped when you run pre-commit checks in your CI system**.
29
29
30
30
### Commit Message Structure
31
+
31
32
Commit messages are validated against the following format:
33
+
32
34
```
33
35
<type>(<optional-scope>): <summary>
34
36
< ... empty line ... >
35
37
<optional body lines>
36
38
<optional body lines>
37
39
<optional body lines>
38
40
```
41
+
39
42
Each component is checked for compliance with the provided or default configuration.
40
43
41
-
**Example output for failed message:**
44
+
If your commit message does not meet the required format, the hook will fail, producing a **report that shows which part of your commit message needs correction**:
The hint message suggests that you can preserve your original message and simply edit it in your default editor, without the need to type the whole message again.
52
+
53
+
To edit failed message, run the command (as the hint suggests):
This command adds a `git again` alias to your machine's Git configuration. You can run then simply `git again` whenever your commit message check fails.
66
+
67
+
---
68
+
69
+
## Setup
48
70
49
71
To integrate the **Conventional Precommit Linter** into your project, add to your `.pre-commit-config.yaml`:
**IMPORTANT:** `commit-msg` hooks require a specific installation command:
86
+
63
87
```sh
64
88
pre-commit install -t pre-commit -t commit-msg
65
89
```
66
90
67
91
**Note:** The `pre-commit install` command by default sets up only the `pre-commit` stage hooks. The additional flag `-t commit-msg` is necessary to set up `commit-msg` stage hooks.
68
92
69
93
For a simplified setup (just with `pre-commit install` without flags), ensure your `.pre-commit-config.yaml` contains the following:
'change: This is commit message without scope with body\n\nThis is a text of body\n# Please enter the commit message for your changes. Lines starting\n# with \'#\' will be ignored, and an empty message aborts the commit.\n#',
60
+
"change: This is commit message without scope with body\n\nThis is a text of body\n# Please enter the commit message for your changes. Lines starting\n# with '#' will be ignored, and an empty message aborts the commit.\n#",
'change: This is commit message without scope with body\n\nThis is a text of body\n# Please enter the commit message for your changes. Lines starting\n# with \'#\' will be ignored, and an empty message aborts the commit.\n#',
59
+
"change: This is commit message without scope with body\n\nThis is a text of body\n# Please enter the commit message for your changes. Lines starting\n# with '#' will be ignored, and an empty message aborts the commit.\n#",
0 commit comments