-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit message length warning #2013
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
Commit message length warning #2013
Conversation
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.
See comments :)
pkg/gui/commit_message_panel.go
Outdated
| } | ||
|
|
||
| func (gui *Gui) checkCommitLengthWarning() { | ||
| commitLength, _ := strconv.Atoi(strings.Trim(gui.Views.CommitMessage.Subtitle, " ")) |
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.
we shouldn't depend on the view's subtitle to access the length of the content. If we wanted to just access the integer I'd change getBufferLength to return an int i.e. directly return strings.Count(view.TextArea.GetContent(), "")-1 and then in RenderCommitLength I'd go:
commitLength := getBufferLength(gui.Views.CommitMessage)
gui.Views.CommitMessage.Subtitle = fmt.Sprintf(" %d ", commitLength)With that said: when people talk about limiting the length of a commit message's lines: they're talking about a line-by-line basis, so looking at the entirety of the commit message won't suffice: we need to instead check if any line exceeds the threshold.
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.
I didn't even consider that, I have a zshrc config that points if I've passed 72 chars only in the commit title. But yeah it makes a lot of sense to extend this to multiple lines.
pkg/config/user_config.go
Outdated
| UnstagedChangesColor: []string{"red"}, | ||
| }, | ||
| CommitLength: CommitLengthConfig{Show: true}, | ||
| CommitLengthWarning: 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.
I'd bundle this inside CommitLengthConfig. I'd also call it WarningThreshold. I'd also default it to disabled (which we can encode via 0) because people have different opinions about whether commit length matters.
4c9b72e to
dcd02d0
Compare
dcd02d0 to
0996f9e
Compare
|
I'm quite unsure about how this should work and would like a second opinion. Right now ALL the text turns red when you pass the amount of chars specified, but comes back to normal when you go to another line, so you have a warning that is based on each line but the text color doesn't persist for each line. Is this the best way or should the text persist? And if it needs to persist, is there any already made way to change the line color and not all text? |
My vision for this feature is to have each line validated separately, with any text past the threshold either turning a different color, or, ideally, autowrapping (maybe have a setting For example, the commit message With With However I recognize that this is an ideal form for me, and will be harder to implement. If possible it would be amazing for my productivity, but I'd settle for anything that gives me an indication of the line length (maybe a vertical ruler, even turning the whole text/line red would technically work, just wouldn't be ideal). |
|
Closing as obsolete, now that we have #3173. |
Really simple implementation of a simple warning for when you commit message pass a certain number, from this issue:
If someone wants any changes in what I did feel free to point out, I thought about adding
commitLengthWarningtoCommitLengthConfigbut I'm not sure since they are related but are not exact the same thing (one is the counter and the other is an effect in the actual message).Thank you!