Skip to content

Fix deprecated precommit #1569

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
wants to merge 2 commits into
base: v4-9-0-test
Choose a base branch
from

Conversation

timsu92
Copy link
Contributor

@timsu92 timsu92 commented Aug 6, 2025

Description

cz init modifies .pre-commit-config.yaml in a deprecated way. This PR fixes that, however, pre-commit must be upgraded to v3.2.0 onwards.

Currently, commitizen is writing something like this to .pre-commit-config.yaml:

- hooks:
  - id: commitizen
  - id: commitizen-branch
    stages:
    - push
  repo: https://github.com/commitizen-tools/commitizen
  rev: v4.8.3

However, pre-commit will complaint that it's deprecated like mentioned in #1560 .
The upstream modification was proposed in pre-commit/pre-commit#2732, and fixed in pre-commit/pre-commit#2808
That means, "pre-push" starts to be usable in v3.2.0, while "push" starts to be deprecated.
This changed has already been stated in https://github.com/commitizen-tools/commitizen/blob/master/docs/README.md?plain=1#L209

Consequently, these modifications were made:

  1. Change from "push" stage to "pre-push" stage
  2. Disallow old pre-commit to be used both in this project and when used by other projects
  3. Update test

Checklist

Code Changes

  • Add test cases to all the changes you introduce
  • Run poetry all locally to ensure this change passes linter check and tests
  • Manually test the changes:
    • Verify the feature/bug fix works as expected in real-world scenarios
    • Test edge cases and error conditions
    • Ensure backward compatibility is maintained
    • Document any manual testing steps performed
  • Update the documentation for the changes

Documentation Changes

  • Run poetry doc locally to ensure the documentation pages renders correctly
  • Check and fix any broken links (internal or external) in the documentation

When running poetry doc, any broken internal documentation links will be reported in the console output like this:

INFO    -  Doc file 'config.md' contains a link 'commands/bump.md#-post_bump_hooks', but the doc 'commands/bump.md' does not contain an anchor '#-post_bump_hooks'.

Expected Behavior

See commitizen generates config like this:

- hooks:
  - id: commitizen
  - id: commitizen-branch
    stages:
    - pre-push
  repo: https://github.com/commitizen-tools/commitizen
  rev: v4.8.3

Steps to Test This Pull Request

  1. cz init
  2. Enable both pre-commit hooks

Additional Context

Close #1560

Copy link

codecov bot commented Aug 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (v4-9-0-test@a69d441). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff               @@
##             v4-9-0-test    #1569   +/-   ##
==============================================
  Coverage               ?   97.98%           
==============================================
  Files                  ?       58           
  Lines                  ?     2680           
  Branches               ?        0           
==============================================
  Hits                   ?     2626           
  Misses                 ?       54           
  Partials               ?        0           
Flag Coverage Δ
unittests 97.98% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Lee-W Lee-W changed the base branch from master to v4-9-0-test August 7, 2025 02:18
@Lee-W Lee-W changed the base branch from v4-9-0-test to master August 7, 2025 02:20
@Lee-W Lee-W force-pushed the fix_deprecated_precommit branch from 721e7ea to 9f063cd Compare August 7, 2025 02:32
@Lee-W Lee-W changed the base branch from master to v4-9-0-test August 7, 2025 02:32
timsu92 added 2 commits August 7, 2025 10:38
Original "push" stage has been deprecated since pre-commit v3.2.0. See pre-commit/pre-commit#2732 and pre-commit/pre-commit#2808 for detailed information.
@Lee-W Lee-W force-pushed the fix_deprecated_precommit branch from 2841bcc to a893655 Compare August 7, 2025 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cz init generates deprecated pre-commit configuration
2 participants