Skip to content

pre-commit fail even if the problem is fixed automatically #1434

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

Open
bearomorphism opened this issue May 18, 2025 · 0 comments
Open

pre-commit fail even if the problem is fixed automatically #1434

bearomorphism opened this issue May 18, 2025 · 0 comments

Comments

@bearomorphism
Copy link
Contributor

bearomorphism commented May 18, 2025

Description

Every time I try to commit something and hope the format should be fixed automatically, the pre-commit Format fails.

Yes, the format issue is fixed, but the commit fails.

Then I either have to git commit -a or cz c -a --retry to try again.

I haven't encountered similar issues when I worked on npm projects with husky pre-commit hooks + something like prettier --write.

commitizen-py3.13➜  commitizen git:(tmp) ✗ git commit -a
Check hooks apply to the repository.......................(no files to check)Skipped
Check for useless excludes................................(no files to check)Skipped
check vcs permalinks..........................................................Passed
fix end of files..............................................................Passed
trim trailing whitespace......................................................Passed
debug statements (python).....................................................Passed
don't commit to branch........................................................Passed
check for merge conflicts.....................................................Passed
check toml................................................(no files to check)Skipped
check yaml................................................(no files to check)Skipped
detect private key............................................................Passed
blacken-docs..................................................................Passed
Run codespell to check for common misspellings in files.......................Passed
Format........................................................................Failed
- hook id: format
- files were modified by this hook

Poe => ruff check --fix commitizen tests
All checks passed!
Poe => ruff format commitizen tests
1 file reformatted, 108 files left unchanged

Linters.......................................................................Passed

Image

Steps to reproduce

  1. Switch to an unprotected branch, ex git switch -c tmp
  2. Randomly insert some blank lines in a .py file to break the format
  3. Run git commit -am "doc: xyz" --allow-empty

Current behavior

The format is fixed, but no new git commit.

Desired behavior

The format should be fixed and there should be a new commit doc: xyz with the fixed change.

Screenshots

No response

Environment

Commitizen Version: 4.7.2
Python Version: 3.13.2 (main, May 12 2025, 02:57:09) [Clang 17.0.0 (clang-1700.0.13.3)]
Operating System: Darwin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant