-
-
Notifications
You must be signed in to change notification settings - Fork 295
Description
Description
Short summary
When I am in a new environment and run cz init
and enable pre-commit hooks, the .pre-commit-config.yaml is generated with the commitizen-branch hook and "push" stage which is deprecated.
Detailed
When running the command cz init
i.e. with the following configuration:
? Please choose a supported config file: .cz.toml
? Please choose a cz (commit rule): (default: cz_conventional_commits) cz_conventional_commits
? Choose the source of the version: commitizen: Fetch and set version in commitizen config (default)
No Existing Tag. Set tag to v0.0.1
? Choose version scheme: semver
? Please enter the correct version format: (default: "$version")
? Create changelog automatically on bump Yes
? Keep major version zero (0.x) during breaking changes Yes
? What types of pre-commit hook you want to install? (Leave blank if you don't want to install) [commit-msg]
commitizen pre-commit hook is now installed in your '.git'
The resulting .pre-commit-config.yaml looks like this:
repos:
- hooks:
- id: commitizen
- id: commitizen-branch
stages:- push
repo: https://github.com/commitizen-tools/commitizen
rev: v4.2.1
- push
Running the command pre-commit
will show the warning:
[WARNING] hook id commitizen-branch
uses deprecated stage names (push) which will be removed in a future version. run: pre-commit migrate-config
to automatically fix this.
When I run pre-commit migrate-config.yaml
the configuration will result in:
repos:
- hooks:
- id: commitizen
- id: commitizen-branch
stages:- pre-push
repo: https://github.com/commitizen-tools/commitizen
rev: v4.2.1
- pre-push
--> the stage of the commitizen-branch hook is "pre-push" instead of "push"
Possible Solution
The pre-commit migrate-config.yaml is directly created with the "pre-push" stage.
So that the complete config looks like:
- hooks:
- id: commitizen
- id: commitizen-branch
stages:- pre-push
repo: https://github.com/commitizen-tools/commitizen
rev: version
- pre-push
Additional context
When I understand the code correctly, the configuration is created in the _install_pre_commit_hook method where the "stages" property is set to ["push"] instead of ["pre-push"]:
commitizen/commitizen/commands/init.py
Line 333 in b2e9c1b
{"id": "commitizen-branch", "stages": ["push"]}, |
Related issues
No response