Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prefixing commit message in vs code with branch name

Is there away to make VS Code automatically prepend branch name in commit message textarea?

Like if I'm on branch 'ID-7345' and just updated e.g. React.js version, I need to write:

ID-7345: updated React.js to version 16.0

and I would like to omit writing branch name each time there, so wherever I access this page I will see ID-7345: pre-populated and cursor blinking after it.

like image 491
zmii Avatar asked Mar 07 '23 12:03

zmii


1 Answers

There is now a VS Code extension that does the job: https://marketplace.visualstudio.com/items?itemName=srmeyers.git-prefix. By default, a click on the extension button will put into your commit message this label: "[YourBranchName]". Into the extension settings, there are 3 parameters if you want to fine tune the label (copy/paste from the extension page):

  • gitPrefix.pattern: Regular expression pattern to match in the branch name. Default matches entire branch name.
  • gitPrefix.patternIgnoreCase: Ignore case in pattern. Default is
    false.
  • gitPrefix.replacement: Regular expression replacement string to place into commit message. Default is "[$1] ".
like image 128
TiK Avatar answered Mar 15 '23 04:03

TiK