Skip to content

cz init generates deprecated pre-commit configuration #1560

@jonaskoeASYS

Description

@jonaskoeASYS

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:

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:

--> 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:

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"]:

{"id": "commitizen-branch", "stages": ["push"]},

Related issues

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions