-
-
Notifications
You must be signed in to change notification settings - Fork 281
[Feature Request] Line length warning #191
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
Comments
You mean for the commit subject? Where would we add this? Remember that this is not a problem for the changelog. I'm not sure why the line length was chosen to be 72. |
The first line of our generated commit. e.g., I guess the number is from here |
IMO we should add it as a config parameter ( I like the plugins idea, not sure how to hook everything haha but it's interesting |
This could be my next target after #128 haha. Also, if my memory serves me right, you've mentioned implementing changelog-hooks (like email-hooks or slack-hooks). Do you have any idea how we should group them. Add them into to this repo as extra deps? Or, create another repo like commitizen-changelog-hooks? |
I was thinking more like separate packages, so people can choose which one to install:
and then in your hooks = [
"slack-hook",
"email-hook"
] |
I agree with the 72 character default for the commit title, as that's the max github displays in the commit history. |
Here's a way to implement similar functionality #331 (comment). Not yet tried this functionality on cz-cli. might need some investigation |
Hi there! the sample code is:
This approach considered all text validation results are always |
Thanks for sharing! This is really helpful. I'm thinking of making those two behavior confiugrable |
That's super cool finding! |
Hello everyone! Result: import questionary
from questionary import Validator, ValidationError
class NameValidator(Validator):
def validate(self, document):
text_len = len(document.text)
if text_len > 72:
raise ValidationError(
message=f"({text_len}/72)",
cursor_position=text_len,
)
questionary.text("Hi, type anything below:\n", validate=NameValidator).ask() Any thoughts on this? |
I'm good with it 👍 |
I'm trying to work on this issue, and found one interesting bottleneck: "type": "input",
"name": "subject",
# added validator cannot access the results from other questions
"validate": SomeValidator,
"filter": parse_subject,
"message": (
"Write a short and imperative summary of the code changes: (lower case and no period)\n"
), Therefore, before questionary supports the desired access, one workaround is to validate the length in, for example,
Please refer to #557. Any ideas or better solutions are welcome! |
I totally understand it's not desirable but I don't think there's any particular issue in this case, but couldn't this be achieved with a global variable update on type and scope update? I'm new to Commitizen and Python in general so take any of my suggestions with a pinch of salt, but wouldn't doing something like below work? MESSAGE_LENGTH = 0
def parse_type(text):
global MESSAGE_LENGTH
MESSAGE_LENGTH += len(text)
def parse_scope(text):
if not text:
return ""
global MESSAGE_LENGTH
scope = text.strip().split()
if len(scope) == 1:
MESSAGE_LENGTH += len(scope[0])
return scope[0]
text = "-".join(scope)
MESSAGE_LENGTH += len(text)
return text Then use MESSAGE_LENGTH in your |
Would it be possible to also check the configured line length with |
maybe we could make the length an option 🤔 @kevin1kevin1k will you be interested in it? |
Description
It's recommended to have only 72 characters. We could add a warning or a hint if the generated title might exceed 72.
Possible Solution
Add a line hint like vim
Additional context
Related Issue
The text was updated successfully, but these errors were encountered: