microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.66k stars 28.68k forks source link

Git commit template only loaded when VSC is loaded #39048

Closed tennisfar closed 6 years ago

tennisfar commented 6 years ago

Tested on:

Steps to Reproduce:

  1. Make sure you have a Git template set up. See this closed issue for more details: https://github.com/Microsoft/vscode/issues/7830), or simply create a .gitmessage template file with some text in it, and link to it from inside your .gitconfig file, something like this:
    [commit]
    template = ~/.gitmessage
  2. Open VSC.
  3. Make a change in your code, open Git sidebar, see the commit message is the same as you've put in .gitmessage.
  4. Modify the content of .gitmessage without closing VSC.
  5. Make another change in your code, close the Git sidebar, play around. Basically do whatever you like except closing VSC.

Problem is.. how to make VSC update the commit message to the latest content in .gitmessage without restarting VSC?

The reason why I'm needing this is that i have a post-checkout git hook that modifies .gitmessage, adding part of the name of the branch I've switched to. If, for example, I switch to a branch named feature/IU-1234-foo-bar, then my template is updated with IU-1234.

It seems like I can only make VSC re-read .gitmessage by restarting VSC.

joaomoreno commented 6 years ago

Added a git.restoreCommitTemplate command which you can invoke to refresh the commit message with the template.

ramya-rao-a commented 5 years ago

@joaomoreno The restore command is not available in the command pallet. I had to assign a keybinding to the command and then invoke it via the keybinding.

Was this intended?

joaomoreno commented 5 years ago

Yeah, I don't think it's a command worth putting in the command palette. Seems to be very specific for users who actively modify .gitmessage, doesn't happen often.

tennisfar commented 5 years ago

@joaomoreno Thanks. :)