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

Accept multiline comments in body #44

Open
Nosfistis opened this issue Nov 4, 2021 · 4 comments
Open

Accept multiline comments in body #44

Nosfistis opened this issue Nov 4, 2021 · 4 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Nosfistis
Copy link

The body of the commit message should accept multiline comments, i.e. paragraphs. According to commitizen/cz-cli#398, the body type should be editor, instead of input. I can provide a PR if needed.

{
type: 'input',
name: 'body',
message:
'Provide a longer description of the change: (press enter to skip)\n',
default: options.defaultBody
},

@juliuscc
Copy link
Collaborator

juliuscc commented Nov 5, 2021

Hi! Thanks for creating this issue!

My interpretation of that issue is that it is possible to use an editor in your own fork, but that cz-cli has decided to not do it. I have concerns with introducing an editor input instead of a one-line input.

I agree with you that it's much easier to create nice commit messages in a much better format. I do however think there are some very large drawbacks. Firstly the default editor is vim, which scares a large portion of new developers. I think this library should be a helpful tool especially for new developers. Secondly, I think it's a bit distracting to get redirected into some other interface (for all developers who have configured vs code as their default editor).

In my experience, most commit messages are short enough to be one line, and the few messages that I want to have longer, I write using GitKraken or in my favorite editor by just running git commit. I don't think we should optimize for the infrequent use case of having to write long commit messages when the majority of commit messages are short and where this change would hurt that majority of use cases.

With that said, I do agree that I would want to be able to write multiline commits with this tool as well (even though it's more of a nice to have). And it can also be seen as a motivator to write better and longer commit messages.

I looked into creating my own inquirer prompt that would somehow allow multiline inputs but still stay in the same terminal context. We don't want to reinvent the wheel by creating a new fully-fledged editor but what we could do is allow you to write one line at a time. When you have written a line and press enter you get a new input. If you leave it empty we go to the next prompt but as long as you keep writing stuff you will get new inputs. This wouldn't allow you to go back and delete or change your commit message but maybe that's fine.

What do you think about all of this?

@Nosfistis
Copy link
Author

I understand your concerns, and thanks for the detailed response. I did not realize that this is a feature not provided in cz-cli either. I do think that it is a great addition though, since I frequently write multi-line comments. I believe commits should be a kind of documentation, and having one-liner descriptions makes it harder.

Your suggestion sounds like a nice compromise. I think that a hint of that behavior would help a lot, since an empty line acting as an end is not that intuitive.

There are some more suggestions that I would find more intuitive, although I am not sure if they are technically feasible. The discussion in cz-cli mentioned potentially parsing \n or \r\n sequences. However, I find using Shift + Enter is a common shortcut in the web when entering new lines in fields that are submitted on Enter. If the terminal would allow such handling, I think it would be best.

@juliuscc
Copy link
Collaborator

juliuscc commented Nov 9, 2021

Yeah, actually that is a great suggestion! If you can detect Shift + Enter I think that is the best. It is easy to add a small hint saying (press Shift + Enter for a new line). I think the easiest implementation is to create a custom prompt.

The greatest challenge is probably how to support going back to previous lines and delete stuff, but maybe you don't have to support that.

@Nosfistis
Copy link
Author

Indeed it might be out of this scope deleting previous lines, although I do think that it might be possible with some trickery. However, this is still just an extra "nice to have".

@Saeger Saeger added good first issue Good for newcomers help wanted Extra attention is needed labels Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants