Skip to content

Conversation

@benediktziegler
Copy link

@benediktziegler benediktziegler commented Dec 1, 2025

Description

This PR adds functionality to customise the commit message validation and to format the InvalidCommitMessageError to give better/more detailed feedback to the user.

Checklist

  • Add test cases to all the changes you introduce
  • Run ./scripts/format and ./scripts/test locally to ensure this change passes linter check and test
  • Test the changes on the local machine manually
  • Update the documentation for the changes

Expected behavior

The developer of a custom commitizen class can override the validate_commit_message and format_error_message methods to perform more complex commit message format checks then just a regex match and give more detailed feedback on failure.

Steps to Test This Pull Request

Run the the test_check_command_with_custom_validator_succeed and test_check_command_with_custom_validator_fail tests in test_check_command.py.

Additional context

This PR implements and fixes the comments from #648.
Cleaned up version of #1236

@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             v4-11-0    #1680   +/-   ##
==========================================
  Coverage           ?   98.68%           
==========================================
  Files              ?       60           
  Lines              ?     2655           
  Branches           ?        0           
==========================================
  Hits               ?     2620           
  Misses             ?       35           
  Partials           ?        0           
Flag Coverage Δ
unittests 98.68% <100.00%> (?)

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just note that this file will probably be removed in #1657

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants