carloscuesta / gitmoji-cli

A gitmoji interactive cli tool for using emojis on commits. 💻
https://www.npmjs.com/package/gitmoji-cli
MIT License
4.59k stars 206 forks source link

Add an option that simply prints out the resulting commit, to support third-party tools #516

Closed goodevilgenius closed 3 years ago

goodevilgenius commented 3 years ago

Hello @carloscuesta!

Issue: My job requires me to use subversion, and I'd really like to use gitmoji with svn. I normally use git-svn, but one of our repos has some weirdness that only works with the official subversion client.

I wanted to create a script that I could use that would call gitmoji to create the commit message, and pass it to svn commit. However, gitmoji --hook calls git rev-parse which fails outside of a git repo. And gitmoji --commit obviously calls git commit directly.

I propose an option, something like gitmoji --print which would print the resulting commit message to stdout, and gitmoji --print --file <filename> which would write the commit message to <filename>.

OS: Linux Mint gitmoji -v: 3.2.15 Node version: 12.10.0 (although I can switch to any other version)

carloscuesta commented 3 years ago

Hello @goodevilgenius

Thanks for opening an issue 😊

I think that the --print command won't be a really great addition to the cli, since the purpose of it would be to handle a really specific use-case.

I know this is not ideal but If you want to keep using gitmoji on the repo that is not compatible with git-svn what about using the gitmoji --search command to find the emoji that you're looking for?

You can use it like this:

gitmoji --search "text to search" or gitmoji -s "text to search"

Screenshot 2020-12-15 at 15 10 10

What do you think?

goodevilgenius commented 3 years ago

Not really ideal at all. I was hoping to be able to use the already existing interactive commit message workflow.

But, at least to get the emoji, I can hack together something like:

gitmoji -l | fzf | awk -F ' ' '{print $1}'

That will give me an interactive search with fzf, and using awk to get just the emoji from the output.

I could possibly combine that with a previous input. Something like:

read -p 'Keyword emoji search? ' keyword
gitmoji -s "$keyword" | fzf | awk -F ' ' '{print $1}'

It's still really awkward, especially since gitmoji by itself already has the exact interface I need.

If you're not willing to work on it, would you be open to a PR adding the functionality? I'm pretty sure I could build that myself.

carloscuesta commented 3 years ago

I'm not quite sure that I'll be accepting a PR for that, because as I said I don't think it is a great addition to the functionality of the cli itself. I think it solves an edge case and outside of this edge case the --print command won't be used at all