Closed dmstern closed 5 years ago
(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:
Maybe running it on every `git.refresh. isn't too bad, but I'd definitely put that behind a setting. PR?
@dmstern Can you try your flow on today's Insiders? Thanks to another issue's fix, we now support live reloading of the template message:
I believe this would help you and render https://github.com/microsoft/vscode/pull/75767 obsolete. What do you think?
@joaomoreno Wow, very cool! This is even better than #75767. I'll close my PR.
@joaomoreno I'm not sure exactly the extent you mean by 'live reloading'--when I edit my message file, I need to (manually) hit refresh in the git sidebar to have it update the default commit message--it doesn't update automatically when the template it saved. If this is the intended behavior, feel free to mark this issue as verified
🙂
@connor4312 Is the template file you picked inside the workspace folder? If it is outside, we won't have file events hooked up to it.
Easiest way to test is:
template
file in workspacegit config commit.template template
Then, changes in template
should eventually be reflected in the commit box.
That works :)
Background
In #39048, @joaomoreno says about the command
git.restoreCommitTemplate
:This might be true, but there are definitely more actions (than just
commit
) where it would make sense to read the git commit template, because if you know what you can do with this, this is so damn useful. :)Problem:
Personally, I use the git commit template to follow our team's git commit message and branch naming conventions, which says that the commit message and the branch you are working on have to be prefixed with the id of the corresponding Jira issue.
So I created a git hook for writing the recently used commit message into the commit template on
post-commit
and also a hook onpost-checkout
to write the current branch name (title-cased) into the commit template when I create a new branch. :heavy_check_mark: When I commit something, the git commit template updates and the last commit message stays in the scm message box. :negative_squared_cross_mark: But in order to get the updated content from that template after agit checkout
, I have to invokegit.restoreCommitTemplate
.Temporarily I could fix this with a macro extension and mapped the
workbench.view.scm
keyboard shortcut to my new macro, which does both (git.restoreCommitTemplate
andworkbench.view.scm
). But (a) this works only with this shortcut, not if I click on the scm icon in the activity bar and (b) I think this behavior should be possible without an extension.Possible solution:
Please invoke
git.restoreCommitTemplate
every timeworkbench.view.scm
is invoked or on everygit.refresh