Skip to content

Commit 86f91fc

Browse files
committed
docs: update documentation to reflect 'prek' integration and improve clarity
1 parent 331adff commit 86f91fc

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

docs/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ This command is particularly useful for automation scripts and CI/CD pipelines.
182182

183183
For example, you can use the output of the command `cz changelog --dry-run "$(cz version -p)"` to notify your team about a new release in Slack.
184184

185-
#### Pre-commit Integration
185+
#### Prek and Pre-commit Integration
186186

187187
Commitizen can automatically validate your commit messages using pre-commit hooks.
188188

@@ -200,17 +200,18 @@ repos:
200200
201201
2. Install the hooks:
202202
```sh
203-
pre-commit install --hook-type commit-msg --hook-type pre-push
203+
prek install --hook-type commit-msg --hook-type pre-push
204204
```
205205

206206
| Hook | Recommended Stage |
207207
| ----------------- | ----------------- |
208208
| commitizen | commit-msg |
209209
| commitizen-branch | pre-push |
210210

211-
> **Note**: Replace `master` with the [latest tag](https://github.com/commitizen-tools/commitizen/tags) to avoid warnings. You can automatically update this with:
211+
> [!Note]
212+
> Replace `master` with the [latest tag](https://github.com/commitizen-tools/commitizen/tags) to avoid warnings. You can automatically update this with:
212213
> ```sh
213-
> pre-commit autoupdate
214+
> prek autoupdate
214215
> ```
215216
216217
For more details about commit validation, see the [check command documentation](https://commitizen-tools.github.io/commitizen/commands/check/).

docs/tutorials/auto_check.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,29 @@
22

33
## About
44

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.
66

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.
88

99
## How to
1010

1111
There are two common methods for installing the hooks:
1212

1313
### Method 1: Using pre-commit hook frameworks (Recommended)
1414

15-
Using pre-commit frameworks is the recommended approach as hook installation, updates, and execution are handled automatically.
16-
These are two common pre-commit hooks:
15+
Using pre-commit hook frameworks is the recommended approach because hook installation, updates, and execution are handled automatically.
16+
Two common frameworks are:
1717
- [prek](https://prek.j178.dev) (faster)
1818
- [pre-commit](https://pre-commit.com/)
1919

20+
In the steps below, we'll use `prek`.
21+
2022
#### Step 1: Install prek
2123

2224
```sh
2325
python -m pip install prek
2426
```
2527

26-
2728
#### Step 2: Create `.pre-commit-config.yaml`
2829

2930
Create a `.pre-commit-config.yaml` file in your project root directory with the following content:
@@ -49,12 +50,11 @@ Install the configuration into Git's hook system:
4950
prek install --hook-type commit-msg
5051
```
5152

52-
5353
The hook is now active! Every time you create a commit, commitizen will automatically validate your commit message.
5454

5555
### Method 2: Manual Git hook installation
5656

57-
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.
57+
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.
5858

5959
#### Step 1: Create the commit-msg hook
6060

@@ -95,7 +95,7 @@ git commit -m "invalid commit message"
9595
git commit -m "feat: add new feature"
9696
```
9797

98-
If the hook is working correctly, invalid commit messages will be rejected with an error message explaining what's wrong.
98+
If the hook is working correctly, invalid commit messages are rejected with an error explaining what's wrong.
9999

100100
## What happens when validation fails?
101101

@@ -128,12 +128,12 @@ pattern: ^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))
128128
- **Verify commitizen is installed**: Run `cz --version` to confirm commitizen is available in your PATH
129129
- **Check Git version**: Ensure you're using a recent version of Git that supports hooks
130130

131-
### Pre-commit hook not working
131+
### Prek hook not working
132132

133-
- **Verify installation**: Run `pre-commit --version` to confirm pre-commit is installed
134-
- **Reinstall the hook**: Try running `pre-commit install --hook-type commit-msg` again
133+
- **Verify installation**: Run `prek --version` to confirm pre-commit is installed
134+
- **Reinstall the hook**: Try running `prek install --hook-type commit-msg` again
135135
- **Check configuration**: Verify your `.pre-commit-config.yaml` file is valid YAML and in the project root
136-
- **Update hooks**: Run `pre-commit autoupdate` to update to the latest versions
136+
- **Update hooks**: Run `prek autoupdate` to update to the latest versions
137137

138138
### Bypassing the hook (when needed)
139139

@@ -150,4 +150,5 @@ git commit --no-verify -m "your message"
150150

151151
- Learn more about [Git hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks)
152152
- See the [check command documentation](../commands/check.md) for more validation options
153+
- Check out [prek documentation](https://prek.j178.dev/) for advanced hook management
153154
- Check out [pre-commit documentation](https://pre-commit.com/) for advanced hook management

0 commit comments

Comments
 (0)