Skip to content

feature: changelog_message_build_hook can remove message by returning a falsy value #1001

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

Merged

Conversation

noirbizarre
Copy link
Member

Description

This PR allows changelog_message_build_hook to remove commits from the changelog just by returning None or any falsy value.
Testing this PR made me realize than the hook was ignored for body messages and fix this case.

Note: some changes are just formatting from the scripts/format execution.

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 feature: if the changelog_message_build_hook return a falsy value (None or {} from expected types), the commit will be skipped into the changelog.

Side-effect fix: the hook is also executed on the parsed body message given it is generated using the same commit_parser

Steps to Test This Pull Request

  1. Create and use a custom plugin class
  2. Override its changelog_message_build_hook
  3. Check that commit for which it returned None are not included in the changelog

Additional context

Next step will be to allow the opposite: allows this same hook to create multiple changelog entries from a single commit (by allowing returning a list or tuple I think)

Sorry, something went wrong.

Verified

This commit was signed with the committer’s verified signature.
noirbizarre Axel H.
… returning a falsy value
@noirbizarre noirbizarre force-pushed the feature/changelog-hook-can-drop branch from f81f541 to f6d8e29 Compare March 5, 2024 12:43
@noirbizarre noirbizarre added type: feature A new enhacement proposal scope: plugin labels Mar 5, 2024
Copy link

codecov bot commented Mar 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.49%. Comparing base (120d514) to head (f6d8e29).
Report is 192 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1001      +/-   ##
==========================================
+ Coverage   97.33%   97.49%   +0.16%     
==========================================
  Files          42       55      +13     
  Lines        2104     2399     +295     
==========================================
+ Hits         2048     2339     +291     
- Misses         56       60       +4     
Flag Coverage Δ
unittests 97.49% <100.00%> (+0.16%) ⬆️

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.

@woile woile merged commit 71a594d into commitizen-tools:master Mar 6, 2024
@noirbizarre noirbizarre deleted the feature/changelog-hook-can-drop branch March 6, 2024 11:43
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.

None yet

2 participants