Skip to content

fix(pre-commit): Correct pre-commit Hook Definition #514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
- id: commitizen
name: commitizen check
description: "Check whether the commit message follows commiting rules"
entry: cz check --commit-msg-file
entry: cz check
args: [--allow-abort, --commit-msg-file]
stages: [commit-msg]
language: python
language_version: python3
require_serial: true
minimum_pre_commit_version: "0.15.4"
minimum_pre_commit_version: "1.4.3"
2 changes: 1 addition & 1 deletion commitizen/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def _install_pre_commit_hook(self):
cz_hook_config = {
"repo": "https://github.com/commitizen-tools/commitizen",
"rev": f"v{__version__}",
"hooks": [{"id": "commitizen", "stages": ["commit-msg"]}],
"hooks": [{"id": "commitizen"}],
}

config_data = {}
Expand Down
1 change: 0 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ repos:
rev: master
hooks:
- id: commitizen
stages: [commit-msg]
```

After the configuration is added, you'll need to run
Expand Down
3 changes: 1 addition & 2 deletions docs/auto_check.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ repos:
rev: v1.17.0
hooks:
- id: commitizen
stages: [commit-msg]
```

* Step 3: Install the configuration into git hook through `pre-commit`
Expand Down Expand Up @@ -51,7 +50,7 @@ Open the file and edit it:
```sh
#!/bin/bash
MSG_FILE=$1
cz check --commit-msg-file $MSG_FILE
cz check --allow-abort --commit-msg-file $MSG_FILE
```

Where `$1` is the name of the temporary file that contains the current commit message. To be more explicit, the previous variable is stored in another variable called `$MSG_FILE`, for didactic purposes.
Expand Down
2 changes: 1 addition & 1 deletion tests/commands/test_init_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def ask(self):
cz_hook_config = {
"repo": "https://github.com/commitizen-tools/commitizen",
"rev": f"v{__version__}",
"hooks": [{"id": "commitizen", "stages": ["commit-msg"]}],
"hooks": [{"id": "commitizen"}],
}

expected_config = (
Expand Down