benjaminadk / emojigit

VS Code extension for composing Gitmoji commit messages
https://marketplace.visualstudio.com/items?itemName=benjaminadk.emojis4git
36 stars 4 forks source link

Feature request: #5

Open Barben360 opened 5 years ago

Barben360 commented 5 years ago

Hello it's me again and again! Would it be possible to add the possibility to add comments to the commit?

From git commit documentation:

-m , --message= Use the given as the commit message. If multiple -m options are given, their values are concatenated as separate paragraphs.

This means that comments could be appended in the command line reusing -m "comment line 1" -m "comment line 2", etc

Barben360 commented 5 years ago

However this inserts a double-backline between each paragraph, which is not exactly a multiline comment.

benjaminadk commented 5 years ago

Are you thinking something like what is described in this article? This format is:

git commit -m ":emoji: Title with max of 50 chars \n\n Body with max of 72 chars"

Is it possible with using newline characters?

Barben360 commented 5 years ago

Yes I'm thinking about this. However I've just tested, using \n character doesn't go back to line, it just inserts characters \ and n in the commit title.

Barben360 commented 5 years ago

Some hint here: git commit -F <filename> creates the commit message from a file. Therefore if you generate a temp file with the commit title and message (including multiline), you can just generate the temp file and generate the line: git commit -F <filename> && rm <filename>. However the rm will only work on unix-based distributions. I think you should consider applying the commit and removing the file directly in your extension and not just generate the command line.

benjaminadk commented 5 years ago

So does the user create the temp file in vscode? Or do I parse the user input from the vscode UI and generate a file from that? I have to look into vscode api and see if it offers a multiline input. Right now all I can think of is parsing the single line text for the \n character and formatting a template string and creating the temp file with the extension.

Barben360 commented 5 years ago

As a user I think it is a bad idea to make the user create the temp file. This is quite a lot of work for just a commit. Generating it would be the best. If multiline input is possible in quick actions, then this would be the best solution. I have no idea if this is possible, but I think not. Your solution parsing \n would be quite a good compromise I think. Another solution would be to have a section in "Source control" panel on the left to manage gitmoji commits, multiline in forms is possible here (at least it is for the built-in git message editor). But that would imply a full redesign of your extension.

akaleeroy commented 5 years ago

First of all nice work on the extension! :clap:

I'd like multi-line commits too. I'm coming from using a custom git commit template:

git config --global commit.template ~/.gitmessage.txt

.gitmessage.txt file ↓

# https://gitmoji.carloscuesta.me

# :art: Improving structure / format of the code
# :zap: Improving performance
# :fire: Removing code or files
# ...

Committing looks like: git commit -aCOMMIT_EDITMSG file opens in default editor ↳ track down what kind of commit I want, un-comment it, write my commit message, hit Return twice, write the details, save and close

It's a great experience because you have the full power of a code editor, you get multi-line commits, spell checking, you can set rulers to 50 characters, you get another look at the committed file names and you can change your mind: _Hang on this isn't a :pencil2: Fixing typos it's a :speechballoon: Changing text and literals...

The upsides with your extension are triggering with a command (incl. keybinding) and that sweet sweet fuzzy search command palette menu, instead of doing Ctrl F. I can't figure out how to integrate the commit template workflow directly into VSCode, save for opening a terminal and typing out git commit. If you try to use the Source control panel it forces you into a little textbox.

benjaminadk commented 5 years ago

I am brainstorming. I just found this article and the last option - adding $ between -m and the quoted message. The article says that $ makes the shell honor \n on *nix systems. This works on my Windows 10 machine. This could be an option is vscode settings. Lile allowMultiline or something.


OR - maybe try to integrate with git's flow somehow. If extensions could write to user's machine i guess it could overwrite the template and open the editor with the selected emoji and text on the subject line on each commit. not sure if this is possible or the best approach though.

Barben360 commented 5 years ago

Nice discovery! I also found out that you can commit directly a text file as a message:

git commit -F message.txt

In the documentation of VSCode extensions, I can see several interesting things:

benjaminadk commented 5 years ago

I added basic multiline support. Having a problem with my azure devops account. I didnt renew an email address i used for the microsoft account i created the account for this extension with. Bottom line is that i cant publish an update at this point. I am looking into it.

pke commented 4 years ago

@benjaminadk can you submit updates by now again?