-
Notifications
You must be signed in to change notification settings - Fork 103
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
New Rule: title-min-length #140
New Rule: title-min-length #140
Conversation
4dd7315
to
bbf88a5
Compare
* Add a new `title-min-length` rule which mimics the `body-min-length` rule in its function. The default min length is set to 5 as per the discussion in jorisroovers#138. * Add a few tests modeled on TitleMaxLength. Signed-off-by: mr.Shu <mr@shu.io>
bbf88a5
to
83ad30f
Compare
@jorisroovers thanks a ton for a very nice tool! I took a quick try on what could the implementation of #138 look like. Please feel free to let me know if there are things that would be worth updating -- should this end up really being part of Thanks again! cc @tjanez |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments/suggestions inline.
Some other places that need updating:
- Enable the rule in the config:
Line 45 in 6a37bae
default_rule_classes = (rules.IgnoreByTitle, - Add the rule and config option to the default config file (used by
gitlint generate-config
when generating a sample .gitlint file) https://github.com/jorisroovers/gitlint/blob/master/gitlint/files/gitlint - As per your suggestion, the docs would need updating. Specifically
docs/rules.md
and the.gitlint
example indocs/configuration.md
violation = rule.validate(u"å" * 72, None) | ||
self.assertIsNone(violation) | ||
|
||
# assert error on line length > 72 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# assert error on line length > 72 | |
# assert error on line length < 5 |
gitlint/rules.py
Outdated
def validate(self, title, _commit): | ||
min_length = self.options['min-length'].value | ||
actual_length = len(title) | ||
if 0 < actual_length < min_length: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would still allow for empty commit titles. I'd expect we'd want to capture this too?
if 0 < actual_length < min_length: | |
if actual_length < min_length: |
I think it would be good to add a test for an empty title specifically to cover this scenario
This is awesome, thanks so much for taking the time! Left some comments in review. I'm currently in a bit of a gitlint hiatus - which will affect when this is released. I will do it before the end of 2020, but might be a while... Appreciate your understanding! |
* Update tests related to the `title-min-length` (mostly cosmetic changes) * Add one more test for empty title. * Add the new `title-min-length` rule to various documentation files. Signed-off-by: mr.Shu <mr@shu.io>
6907bf5
to
458d803
Compare
Thanks for your response @jorisroovers ! I believe I've applied all the changes you've suggested with two notable exceptions:
Feel free to take as much time as would suite you -- I really do not think there is any rush here :) Thanks again! |
Rebased this to the new |
Thanks @jorisroovers -- please let me know if I can be of any help in here. |
Fixed related tests as well.
title-min-length
Merged! Will go out with 0.14.0, which should be soon! |
Add a new
title-min-length
rule which mimics thebody-min-length
rule in its function. The default min length is set to 5 as per the
discussion in Add title-min-length rule #138.
Add a few tests modeled on TitleMaxLength.
Signed-off-by: mr.Shu mr@shu.io