Skip to content

Comments

fix(config): fix contains_commitizen_section failing for completely e…#1874

Merged
woile merged 1 commit intocommitizen-tools:masterfrom
bwachtendorf:fix-empty-files
Feb 18, 2026
Merged

fix(config): fix contains_commitizen_section failing for completely e…#1874
woile merged 1 commit intocommitizen-tools:masterfrom
bwachtendorf:fix-empty-files

Conversation

@bwachtendorf
Copy link
Contributor

Description

The new contains_commitizen_section broke JSON and YAML configs that are completely empty files.
For TOML configs, the check was working as expected and not failing for empty files.
This PR just adds some basic error handling for empty files.

Checklist

Was generative AI tooling used to co-author this PR?

  • Yes (please specify the tool below)

Code Changes

  • Add test cases to all the changes you introduce
  • Run uv run poe 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

No doc changes

Expected Behavior

Commitizen no longer fails on empty JSON/YAML config files.

Steps to Test This Pull Request

  1. create empty config with touch .cz.yaml
  2. run cz --config .cz.yaml check COMMIT..COMMIT
  3. Success
  4. Repeat for .cz.json

Additional Context

Updated commitizen and CI jobs in exisiting repositories started failing. Short investigation revealed new empty config file check did not account for completely empty files.

@codecov
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.99%. Comparing base (b20ba04) to head (ae81982).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1874   +/-   ##
=======================================
  Coverage   97.98%   97.99%           
=======================================
  Files          60       60           
  Lines        2686     2689    +3     
=======================================
+ Hits         2632     2635    +3     
  Misses         54       54           

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

Copy link
Member

@woile woile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@woile woile merged commit 988c81f into commitizen-tools:master Feb 18, 2026
20 checks passed
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.

2 participants