streamich / git-cz

Semantic Git commits
1.65k stars 107 forks source link

New line support #169

Open tvvignesh opened 4 years ago

tvvignesh commented 4 years ago

Hi. Have been using this tool and while its awesome, only issue is that I have to end up writing all the commit messages in a single line.

Is it possible to allow \n or support opening up an editor for long descriptions so that we can have messages formatted properly?

I hope cz-cli is using git-cz and they have posted similar issues like this: https://github.com/commitizen/cz-cli/issues/580 https://github.com/commitizen/cz-cli/issues/398 https://github.com/commitizen/cz-conventional-changelog/issues/41

Any help appreciated. Thanks.

wangjiancn commented 4 years ago

use git commit will open a editor, you can edit commit message in it.

StevenLangbroek commented 4 years ago

@wangjiancn we all know that of course, but maybe we can make for example shift + enter add a new line. the authoring experience in the CLI is great, except for this one annoyance (for us). It feels like a small thing to have to give up the entire experience for.

streamich commented 4 years ago

That is something I would like ot have very much, too. If anyone knows good ways how to achieve this, I'm all ears.

tvvignesh commented 4 years ago

@streamich Git CLI provides multi-line support like this:

git commit -m "this is
> a line
> with new lines
> maybe"

and can also open up editors when configured like this:

git config --global core.editor "nano"

Maybe, the same support can be extended to git-cz if possible? Thanks.

rodrigograca31 commented 4 years ago

This seems to be a valid issue.

I just tested and contrary to my beliefs when the longer description is asked for we can not input SHIFT + ENTER as one would assume.

git-cz follows conventional commits standard, and said standard states:

The description is a short summary of the code changes, e.g., fix: array parsing issue when multiple spaces were contained in string.

A longer commit body MAY be provided after the short description, providing additional contextual information about the code changes. The body MUST begin one blank line after the description.

A commit body is free-form and MAY consist of any number of newline separated paragraphs.

https://www.conventionalcommits.org/en/v1.0.0/

We should allow multiline on the long description but not on the short one.

ping https://github.com/commitizen/cz-cli/issues/580

imekachi commented 3 years ago

Hi guys, any update on this?

https://github.com/commitizen/cz-cli/issues/398#issuecomment-271202071

You can fork the cz-conventional-changelog adapter and change the fields you want to be editor fields instead of input. This would allow you to type multiline input for that fields

https://github.com/streamich/git-cz/blob/c38da987a0c05509947c2410a64132ee599e9f2f/lib/questions/body.js#L5

maybe change this to type: 'editor'?

@streamich what do you think?

rodrigograca31 commented 3 years ago

@imekachi is it that easy?

can you test it and send a PR if it works?

imekachi commented 3 years ago

It kinda works, but the overall experience is not good.

Here is how it looks when the body question is active image

After pressing "Enter", it sent me straight into vim Note: there is no way to skip this question when using type editor (as far as i know) image

The documentation about question type editor says

The editor to use is determined by reading the $VISUAL or $EDITOR environment variables. If neither of those are present, notepad (on Windows) or vim (Linux or Mac) is used.

I think this is not the way to go. It's too hard to use and skip the question. Going with making \n to be an actual line break instead of a text, is a better idea IMO.

rodrigograca31 commented 3 years ago

I currently dont have time to take care of this but if someone finds a good working solution I can review it and merge it

iamWing commented 4 months ago

It kinda works, but the overall experience is not good.

Here is how it looks when the body question is active image

After pressing "Enter", it sent me straight into vim Note: there is no way to skip this question when using type editor (as far as i know) image

The documentation about question type editor says

The editor to use is determined by reading the $VISUAL or $EDITOR environment variables. If neither of those are present, notepad (on Windows) or vim (Linux or Mac) is used.

I think this is not the way to go. It's too hard to use and skip the question. Going with making \n to be an actual line break instead of a text, is a better idea IMO.

Having the same need on multi-line body support and about to take a deeper look into this. Am I understanding you correctly that you'd prefer to use editor for body but at the same time keep the ability to skip providing the body by just pressing enter with no input?

newcodi-ytw commented 2 months ago

god please, anyone know how or when it will be available to use shift + enter to add the new line in long decs, head boom