microsoft / vscode

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

Git commit comment field should pre-populate with git-commit template #74222

Closed ghost closed 5 years ago

ghost commented 5 years ago

If empty, the text field for a Git commit message should pre-load the appropriate git-commit template (as specified in the local or global .gitconfig).

joaomoreno commented 5 years ago

This is implemented. Are you sure you have your git commit template correctly configured?

ghost commented 5 years ago

I thought it was already implemented. It's not working correctly in my VSCode environment. If I invoke git from the command line in the directory I am working in, the template is properly imported into the commit text editor. Launching VSCode, if I stage changes, the commit text field is blank. If I open the VSCode terminal and do a git config -l, it does show the commit.template is populated. I've tried with both absolute and relative paths (/Users/cweiss/.git_commit_template.txt and ~/.git_commit_template). I've tried with VSCode loaded with all extensions disabled.

git version 2.20.1 (Apple Git-117)

vscode version 1.34.0
a622c65b2c713c890fcf4fbf07cf34049d5fe758
x64

From the VSCode terminal:

git config -l
credential.helper=osxkeychain
user.name=Weiss, Chris
user.email=Chris.Weiss@nike.com
core.excludesfile=~/.gitignore_global
core.autocrlf=input
alias.lg=log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit
alias.tree=log --oneline --decorate --all --graph
diff.tool=bc4
difftool.bc4.trustexitcode=true
merge.tool=bc4
mergetool.bc4.trustexitcode=true
color.ui=true
commit.template=~/.git_commit_template.txt
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
include.path=~/.gitconfig_local
user.name=Weiss, Chris
user.email=Chris.Weiss@nike.com
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
joaomoreno commented 5 years ago

Hm... this seems to work for me.

Can you try disabling other extensions? code --disable-extensions.

joaomoreno commented 5 years ago

I've tried with VSCode loaded with all extensions disabled.

Hm... Can you try on another machine?

ChrisWeiss commented 5 years ago

Tested at home, seeing the same results. I should see the template in the field in the attached photo?

Screenshot_5_30_19__7_11_PM

VSCode is looking for it, I see the following in the output window:


Using git 2.20.1 (Apple Git-117) from /usr/bin/git
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: /Users/chrisweiss/workspace/test
> git status -z -u
> git symbolic-ref --short HEAD```
mliq commented 5 years ago

Possibly related to #71550 ?

joaomoreno commented 5 years ago

@ChrisWeiss Yeah the template should appear... not really sure what is happening there. :thinking:

YisraelV commented 5 years ago

I'm checking this.

joaomoreno commented 5 years ago

@ChrisWeiss, https://github.com/microsoft/vscode/issues/71550 turned out to be a user error. Can you triple check?

YisraelV commented 5 years ago

@ChrisWeiss just trying something out: vscode removes all lines that are commented out before populating the textbox, which is quite different than viewing the template in vim, for example.

Does your template contain any non commented out lines?

(@joaomoreno correct me if this is not the intended behavior.

ChrisWeiss commented 5 years ago

Ah! That's the issue! My template is all commented lines providing content guidance. I'd expect the complete raw template to be visible in the commit editor.

joaomoreno commented 5 years ago

Yeah we take those out, since everything in the input box is taken literally, so the comments would be a part of the commit message. I'm merging this together with https://github.com/microsoft/vscode/issues/30562