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

Multiline message support #150

Open
jfstgermain opened this issue Dec 6, 2018 · 9 comments
Open

Multiline message support #150

jfstgermain opened this issue Dec 6, 2018 · 9 comments

Comments

@jfstgermain
Copy link

jfstgermain commented Dec 6, 2018

Hello @carloscuesta!

Issue:
Multiline message do not seem to be supported

ubuntu 18.04:
gitmoji-cli 1.9.2:
node 10.14:

Awesome module!
It would be great if multiline messages were supported!

@silent-e
Copy link

silent-e commented Jan 3, 2019

how about, just like when we used to send emails from the command line, when finished with your message you enter a single dot on it's own line

? Enter the commit message (finish with a single dot on its own line):
[cursor]message message message message [carriage return]
next line next line next line [carriage return]
I've got more to say [carriage return]
and I'll keep saying it until I do this… [carriage return]
.

the final carriage return after the dot proceeds to the next gitmoji section. retro and elegant.

@Pictor13
Copy link

Pictor13 commented Feb 23, 2019

@silent-e that could be nice, but how should it work if one pastes some text?
Also, wouldn't that option prevent from having a (legit) line with just a dot, in the commit message?

I came here because in my case I already had the (long) commit message written somewhere.
I tried to paste it in the commit message, but just the first line is being taken and all the rest is skipped; additionally, it wrongly puts the last line of the message in the "Issue / PR reference".

My use case was me trying to git commit --amend (after a gitmoki -i), but gitmoji is called again and asks me to choose and type everything again, rather than going straight to the message editing or proposing the commit message that is already present.

@borwahs
Copy link

borwahs commented Feb 25, 2019

Ran into a similar need for multiline commit messages.

Here are options I have been exploring to add to gitmoji:

  1. Multiline input for the message prompt
    • two ways to "end" the message: ctrl + d, with single '.'
    • inquirer` currently does not support multiline messages, so we will have to try and get a PR merged or fork until they can.
  2. Pop open an external editor on the commit message step
  3. Pop open an external editor for commit title and message (prepend emoji after)
    • inquirer has an editor option, but it doesn't seem to work with multiple prompts. I get it to open the editor, but it moves on to the next prompt before the editor returns with the message.
  4. Trickery with commit.template (set commit.template with emoji, git commit, unset after).
    • this is a last ditch effort that I thought might work. I want the simplicity of using gitmoji without a hook or some other complex process.

I have started building 1-3 allowing for configurability.

I will open a PR in the next few days once I have something working.

@carloscuesta
Copy link
Owner

Ideally we should implement the multiline support through inquirer, even If they still don't support it, basically to avoid doing hacky things 😄

@borwahs
Copy link

borwahs commented Feb 25, 2019

Ideally we should implement the multiline support through inquirer, even If they still don't support it, basically to avoid doing hacky things 😄

👍 I don't plan to go the hacky route. It was more an exercise in a quick solution locally so I can use it with multiline commits.

  1. Multiline input for the message prompt
  • two ways to "end" the message: ctrl + d, with single '.'
  • inquirer` currently does not support multiline messages, so we will have to try and get a PR merged or fork until they can.

Initially I thought we would need to get multiline support into inquirer. They allow for custom prompts that we can register at runtime. I am going to build a prompt that works with inquirer as multiline and see if I run into any issues.

I'd like to support:

  1. copy + paste into message
  2. ctrl + d to end prompt for message
  3. single . or other identifier to end commit message
  1. Pop open an external editor on the commit message step* Pop open an external editor for commit title and message (prepend emoji after)
  2. inquirer has an editor option, but it doesn't seem to work with multiple prompts. I get it to open the editor, but it moves on to the next prompt before the editor returns with the message.

I did some research on the external editor support with inquirer and it looks to be broken. Going to open an issue there but that might be a long term solution.

@gee1k
Copy link

gee1k commented May 28, 2019

support \n line breaks like commitizen ?

@ghostsquad
Copy link

ghostsquad commented Feb 29, 2020

make the behavior configurable, both as a default in the config file, but also an overriding flag.

Implementation

If you pass --edit you'll be dropped into your user defined editor to create the longer commit body (pre-filled with everything else that's set prior)

Look at the git config for core.editor and use that defined program to write the commit message (which has been pre-filled with everything set prior). You can then fall back to looking for environment variables VISUAL or EDITOR with a hardcoded fallback to vi. Similar to how you can do this with git.

To maintain backwards compatibility, without flags, support single line messages (kind of like git -m).

Users can create bash aliases, or change the configuration to support a default behavior if they wish.

Note, that if the default behavior can be set to --edit behavior in the config, then it would would be also useful to have a --no-edit CLI option, to override the config file.

@thinh105

This comment has been minimized.

@Nixxen
Copy link

Nixxen commented Feb 14, 2022

how about, just like when we used to send emails from the command line, when finished with your message you enter a single dot on it's own line

? Enter the commit message (finish with a single dot on its own line):
[cursor]message message message message [carriage return]
next line next line next line [carriage return]
I've got more to say [carriage return]
and I'll keep saying it until I do this… [carriage return]
.

the final carriage return after the dot proceeds to the next gitmoji section. retro and elegant.

I support this suggestion, but for making it more intuitive, keep asking for a message until a blank string is submitted.
That way you have an "infinite" number of extra message lines, but if you want none, you just press enter to submit a blank line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants