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
feat(prek): supporting prek as an alternative to pre-commit and switching to prek (#1799)
* feat(prek): support 'prek' as an alternative to 'pre-commit' in project_info
* build(prek): replace 'pre-commit' with 'prek' in project configuration
* docs(auto_check): update installation instructions to include 'prek' as an alternative to 'pre-commit'
* test: brought back the `pre-commit` tests along with `prek`
* docs(README): update badge to reflect support for 'prek' instead of 'pre-commit'
* refactor(project_info): enhance pre-commit check to support multiple tools
* docs(auto_check): update auto check installation by only keeping one example
* docs: update documentation to reflect 'prek' integration and improve clarity
* docs(auto_check): add tip for using pre-commit framework alongside prek
* docs: improve formatting and clarity for rendering
* docs(auto_check): clarify usage of pre-commit framework in instructions
> **Note**: Replace `master` with the [latest tag](https://github.com/commitizen-tools/commitizen/tags) to avoid warnings. You can automatically update this with:
212
212
> ```sh
213
-
>pre-commit autoupdate
213
+
>prek autoupdate
214
214
>```
215
215
216
216
For more details about commit validation, see the [check command documentation](https://commitizen-tools.github.io/commitizen/commands/check/).
Copy file name to clipboardExpand all lines: docs/tutorials/auto_check.md
+27-13Lines changed: 27 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,22 +2,35 @@
2
2
3
3
## About
4
4
5
-
To automatically check a commit message prior to committing, you can use a [Git hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks). This ensures that all commit messages follow your project's commitizen format before they are accepted into the repository.
5
+
To automatically check a commit message before committing, use a [Git hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks). This ensures all commit messages match your project's commitizen format before they are accepted into the repository.
6
6
7
-
When a commit message fails validation, Git will reject the commit and display an error message explaining what went wrong. You'll need to amend your commit message to follow the required format before the commit can proceed.
7
+
When a commit message fails validation, Git rejects the commit and displays an error explaining what went wrong. Update the message to the required format before trying again.
8
8
9
9
## How to
10
10
11
11
There are two common methods for installing the hooks:
12
12
13
-
### Method 1: Using [pre-commit](https://pre-commit.com/) (Recommended)
13
+
### Method 1: Using pre-commit hook frameworks (Recommended)
14
14
15
-
[pre-commit](https://pre-commit.com/) is a framework for managing and maintaining multi-language pre-commit hooks. It's the recommended approach as it handles hook installation, updates, and execution automatically.
15
+
Using pre-commit hook frameworks is the recommended approach because hook installation, updates, and execution are handled automatically.
16
+
Two common frameworks are:
16
17
17
-
#### Step 1: Install pre-commit
18
+
1.[prek](https://prek.j178.dev) (faster)
19
+
2.[pre-commit](https://pre-commit.com/)
20
+
21
+
22
+
In the steps below, we'll use `prek`.
23
+
24
+
25
+
!!! tip "Using pre-commit framework"
26
+
If you use pre-commit instead of prek, you can run the same commands. Simply replace prek with pre-commit in the steps below.
27
+
28
+
29
+
30
+
#### Step 1: Install prek
18
31
19
32
```sh
20
-
python -m pip install pre-commit
33
+
python -m pip install prek
21
34
```
22
35
23
36
#### Step 2: Create `.pre-commit-config.yaml`
@@ -42,14 +55,14 @@ repos:
42
55
Install the configuration into Git's hook system:
43
56
44
57
```bash
45
-
pre-commit install --hook-type commit-msg
58
+
prek install --hook-type commit-msg
46
59
```
47
60
48
61
The hook is now active! Every time you create a commit, commitizen will automatically validate your commit message.
49
62
50
63
### Method 2: Manual Git hook installation
51
64
52
-
If you prefer not to use pre-commit, you can manually create a Git hook. This gives you full control over the hook script but requires manual maintenance.
65
+
If you prefer not to use a pre-commit framework, you can manually create a Git hook. This gives you full control over the hook script but requires manual maintenance.
0 commit comments