Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: configurable commit validation#648

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@protonjohn
Copy link

@protonjohnprotonjohn commentedJan 2, 2023
edited
Loading

Allow clients overriding the BaseCommitizen object to have more custom commit message validation beyond just matching a regex schema. This lets clients have custom error messages and more intelligent pattern matching.

Description

This change lets users add certain things like bad word filters or more intelligent task ID listing (for example, make sure one or more IDs appears in the commit message, and in no particular order).

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

Overridevalidate_commit orvalidate_commits inBaseCommitizen for commit validation functions that are expressible in Python, and not just by a regular expression.

Steps to Test This Pull Request

Run thetest_check_custom_validation_succeeds andtest_check_custom_validation_fails test cases intests/commands/test_check_command.py.

Additional context

I noticed during my development that thetest_check_command_with_empty_range case was failing with the error:

commitizen.exceptions.GitCommandError: fatal: ambiguous argument 'master..master': unknown revision or path not in the working tree.

instead of generating its expected output. I did my best to make sure that this failure wasn't related to my changes, since it also reproduced when I ran the test suite againstmaster. It could just be an issue with my local environment.

@protonjohnprotonjohnforce-pushed thejkb/feature/custom-validation branch 2 times, most recently from674f283 tof624bd3CompareJanuary 2, 2023 19:17
@codecov
Copy link

codecovbot commentedJan 2, 2023
edited
Loading

Codecov Report

Base:97.92% // Head:98.01% // Increases project coverage by+0.08% 🎉

Coverage data is based on head(006026a) compared to base(db42a95).
Patch coverage: 91.89% of modified lines in pull request are covered.

❗ Current head006026a differs from pull request most recent headbbe424a. Consider uploading reports for the commitbbe424a to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@##           master     #648      +/-   ##==========================================+ Coverage   97.92%   98.01%   +0.08%==========================================  Files          35       39       +4       Lines        1252     1710     +458     ==========================================+ Hits         1226     1676     +450- Misses         26       34       +8
FlagCoverage Δ
unittests98.01% <91.89%> (+0.08%)⬆️

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

Impacted FilesCoverage Δ
commitizen/commands/init.py87.93% <84.00%> (-3.74%)⬇️
commitizen/cz/customize/customize.py95.34% <96.29%> (+0.26%)⬆️
commitizen/__version__.py100.00% <100.00%> (ø)
commitizen/commands/changelog.py98.86% <100.00%> (ø)
commitizen/commands/check.py100.00% <100.00%> (ø)
commitizen/cz/__init__.py100.00% <100.00%> (ø)
commitizen/cz/base.py100.00% <100.00%> (ø)
commitizen/cz/customize/__init__.py100.00% <100.00%> (ø)
commitizen/exceptions.py100.00% <100.00%> (ø)
commitizen/changelog.py99.43% <0.00%> (ø)
... and3 more

Help us with your feedback. Take ten seconds to tell ushow you rate us. Have a feature suggestion?Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment?Let us know in this issue.

@protonjohnprotonjohnforce-pushed thejkb/feature/custom-validation branch 2 times, most recently from0f30511 to006026aCompareJanuary 2, 2023 19:50
@protonjohn
Copy link
Author

I'm not sure why the patch check is failing - it's complaining about a lack of test code coverage in a file that I didn't touch.

returnNone


classCustomizeCommitValidationCz(CustomizeCommitsCz):
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure why we need to add this Cz rule. Could you describe a bit more? Thanks!

Copy link
Author

Choose a reason for hiding this comment

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

It's mostly so that I could test it in the unit tests, but also to give others an example to work with if they want to use the feature. I didn't see a better place to put it, if you can suggest one I'm happy to put it somewhere :)

Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking of moving it totests. Not sure whether it works

Allow clients overriding the BaseCommitizen object to have more customcommit message validation beyond just matching a regex schema. This letsclients have custom error messages and more intelligent patternmatching.
@protonjohnprotonjohnforce-pushed thejkb/feature/custom-validation branch from006026a tobbe424aCompareJanuary 13, 2023 16:41
@Lee-W
Copy link
Member

It seems the latest version didn't pass the CI.@protonjohn could you please take a look? Thanks!

@Lee-W
Copy link
Member

As this has no update since 2023 and there might be lots of conflicts, I'm going to close this one. Feel free to reopen it, if we still want this improvement in 🙂

@Lee-WLee-W closed thisAug 24, 2025
@benediktzieglerbenediktziegler mentioned this pull requestDec 1, 2025
4 tasks
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@Lee-WLee-WLee-W left review comments

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@protonjohn@Lee-W

[8]ページ先頭

©2009-2025 Movatter.jp