Skip to content
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

feature: Wrap commit body at 72 characters #2627

Closed
jalil-salame opened this issue May 12, 2023 · 12 comments
Closed

feature: Wrap commit body at 72 characters #2627

jalil-salame opened this issue May 12, 2023 · 12 comments
Labels
enhancement New feature or request

Comments

@jalil-salame
Copy link

Is your feature request related to a problem? Please describe.
I recently had some issues where I had to amend commits because their format was wrong; it was expected for the body to wrap at 72 characters.

Describe the solution you'd like
I would like the body of a multiline commit to warp at 72 characters.

Describe alternatives you've considered

  • Set up a git hook to reject commit body lines longer than 72 characters
  • Have a column at 72 characters in lazygit and manually wrap lines
  • Fall back to the editor for multiline commits

Additional context

@jalil-salame jalil-salame added the enhancement New feature or request label May 12, 2023
@jalil-salame jalil-salame changed the title feature: Warn about long lines in commit message feature: Wrap commit body at 72 characters May 12, 2023
@stefanhaller
Copy link
Collaborator

Wrapping lines automatically is not a good idea, I think. This might work for simple paragraphs, but we often have commit messages containing e.g. markdown bullet point lists or other "half-formatted" text, and it's very hard to come up with an automatic wrapping algorithm that doesn't mess these up.

A git hook to reject long lines is good, we have one at work.

What I usually do is "commit with editor" and then use whatever wrapping functionality is built in to the editor I'm using (e.g. Alt-Q on emacs). I don't think it's worth adding such functionality to lazygit's commit editor; it will never be nearly as powerful as a dedicated text editor.

It might, however, be useful to do something simple and draw a ruler at 72 characters so that you can see how long the lines are allowed to be. It would have to be configurable though, I want it at 80. 😄

@jesseduffield
Copy link
Owner

I like the idea of a ruler. I suspect it would be pretty straight-forward to implement

@stefanhaller
Copy link
Collaborator

I would have no idea how to go about it, to be honest. Any pointers?

@mark2185
Copy link
Collaborator

Just pointing out that a PR was in the works for something like that.

@jalil-salame
Copy link
Author

jalil-salame commented May 17, 2023

Just pointing out that a PR was in the works for something like that.

This issue should probably be split into add a marker at X characters and wrap commit body at X characters, the sentiment appears to be that warping should be closed a won't fix or help wanted.

That way they don't overlap

@aubreypwd
Copy link

Wrapping

It would also be nice to have an option we can set that will simply wrap the message where the box ends. It will still commit a long line, but the box itself will wrap. That way I can see my entire message.

CleanShot 2023-08-23 at 10 08 23@2x

⬆️ you can see I can't really see what I typed.

CleanShot 2023-08-23 at 10 09 11@2x

Ideally it would wrap the word, but the character would also be fine. Again, the commit message here in the reflog would be:

Update Rates to be affiliates with Affiliates

A Rate, before this commit, belonged to "Rates" but that isn't accurate, it should belong to Affiliates since they are the one's who have rates.

...without a break.

Rulers

I also think Ruler settings would also be appropriate, we would need 2 (or more?):

One for subject, and one for the description.

@stefanhaller
Copy link
Collaborator

It will still commit a long line, but the box itself will wrap.

I don't think this is desirable. It would encourage people to create commit messages with long lines, which is not a good idea. Commit messages should really be hard-wrapped so that they are readable on any git client.

I also think Ruler settings would also be appropriate, we would need 2 (or more?):
One for subject, and one for the description.

The subject already has a count for how many characters have been typed so far, so I don't think it needs a ruler. Only the body does.

@jwhitley
Copy link
Contributor

In line with @stefanhaller's and @aubreypwd's comments, I think a rule at column 72 is probably ideal as a first step, but I'd take a column count too. I've used git UIs that fool the user into thinking they hard-wrap, only later to discover commit messages which are unreadable in other tooling. So it's nice that lazygit is "WYSIWYG". OTOH, it's also annoying that there's zero formatting support, especially in projects that use hooks to enforce formatting rules. Once there's a column indicator, niceties like auto-word wrap at the end column could be added on top later.

@stefanhaller
Copy link
Collaborator

I disagree now. I know I argued for a ruler before, and against automatic wrapping, but I changed my mind. I started working on automatic wrapping-as-you-type (as shown here), and I won't settle for less now. 😄 For me this is the perfect solution. We shouldn't have to do any manual interactions for wrapping our text to a certain width. You don't do that when typing a paragraph in Word, either.

I hope to have something working that can be tested soon.

@jwhitley
Copy link
Contributor

I hope to have something working that can be tested soon.

Ganbatte!

@stefanhaller
Copy link
Collaborator

Here's a draft PR: #3173. I'm very interested in feedback.

@stefanhaller
Copy link
Collaborator

Fixed by #3173.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants