Skip to content

Commitizen now attempts to enforce its rules the entire history of the project #1818

@KyleMylonakisProtopia

Description

@KyleMylonakisProtopia

Description

It looks like PR #1815 introduced a bug where commitizen now attempts to enforce its rules the entire history of the project instead of just between the source and target commits.

This means repositories which have started using commitizen half-way though, or ones in which a faulty commit was added but was ignored due to wanting to avoid rewriting large amounts of history now have commitizen trigger failures when in the past they did not.

After this change, invalid commit messages on main which previously were fine with commitizen are now tripping this check. Are the environment variable you added in the correct order, and is there supposed to be .. between them?

Steps to reproduce

Ok, I made a minumum reproducing repository: https://github.com/KyleMylonakisProtopia/commitizen-pr-1815-bug
Please fork this repository and you can reproduce the issue with the following commands:

 git clone git@github.com:KyleMylonakisProtopia/commitizen-pr-1815-bug.git
 cd commitizen-pr-1815-bug
 uv venv .venv
 source .venv/bin/activate
 uv pip install -e .
 pre-commit install
 git checkout -b new_branch
 touch new_file
 git add new_file
 git commit -m "feat: add new file"
 git push

For me this fails with the error:

(.venv) ➜  commitizen-pr-1815-bug git:(new_branch)     git push --set-upstream origin new_branch
commitizen check branch..................................................Failed
- hook id: commitizen-branch
- exit code: 14

commit validation: failed!
please enter a commit message in the commitizen format.
commit "2bbee8154e795c7d9f77fd9e190d6d7bf5b9f325": "improperly formatted commit that introduced
"pattern: (?s)(build|bump|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\S+\))?!?: ([^\n\r]+)((\n\n.*)|(\s*))?$
commit "3d9318b341828644f23ff772a6f276be47bf825e": "first commit
"pattern: (?s)(build|bump|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\S+\))?!?: ([^\n\r]+)((\n\n.*)|(\s*))?$


error: failed to push some refs to 'github.com:KyleMylonakisProtopia/commitizen-pr-1815-bug.git'

Current behavior

The entire history of the repo is being analyzed by commitizen.

Desired behavior

The behavior should be as it was in the past where commits outside of those between source and target are ignored.

Screenshots

No response

Environment

The commitizen is coming in from the pre-commit hook. Pre-commit has specified the commitizen version as 4.12.1. This affects at least Mac and Linux systems.

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