-
Notifications
You must be signed in to change notification settings - Fork 101
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
Add an option to force capitalizing the subject line #270
Comments
I don't think this must be done with regular expressions but it would be good to add even if it's off by default |
@novadev94 : Why is that not possible? We are using following regex to check for uppercase character in the description from the conventional commit perspective https://www.conventionalcommits.org/en/v1.0.0/ . I think that's what you are calling subject.
What do I miss? :( One thing to keep in mind, this new rule must not conflict with the contrib rules i.e. the conventional commits. |
@Bearwolves Yes, I should've called them "title" instead of "subject line" to match |
@novadev94 : Got your point. Supporting other language/character shall be allowed, agreed! |
We can add this as a contrib rule. I’ve quickly implemented this a user-defined rule. Can you please verify this works as expected? # filename: captilized_title.py
from gitlint.rules import LineRule, RuleViolation, CommitMessageTitle
class CapitalizedTitle(LineRule):
name = "capitalized-title"
id = "UL1"
target = CommitMessageTitle
def validate(self, title, _commit):
if (len(title) > 0 and not title[0].isupper()):
return [ RuleViolation(self.id, "Title not capitalized", title) ]
return [] Use this [general]
extra-path=my/path/captilized_title.py This would need unit tests and docs. Happy to accept a PR if you’re up for it: https://jorisroovers.com/gitlint/contributing/#contrib-rules |
Bump @novadev94 :-) |
This convention is well-known in the community and deemed a good practice in several articles related to Git commit messages, ex. https://cbea.ms/git-commit/#capitalize.
However, it's currently not possible to get it configured, due to Python stock regex module
re
limitations - we can't have a regex pattern that matches a Unicode uppercase character.There're 2 possible approaches to this:
Implement this as a rule and maybe a default one.
Switch to
regex
module, which has richer regex support with full backward compatibility with there
module.The text was updated successfully, but these errors were encountered: