title: Prepend Git commit message with partial branch name
body: <p>My current branch naming convention is as such:</p>
  
  <pre><code>ticket-45-my-new-feature-branch-description
  </code></pre>
  
  <p>I am currently using this code in my .git/hooks/prepare-commit-msg file to prepend every commit message with the branch name as such:</p>
  
  <pre><code>BRANCH_NAME=$(git branch 2&gt;/dev/null | grep -e ^* | tr -d ' *')
  if [ -n "$BRANCH_NAME" ] &amp;&amp; [ "$BRANCH_NAME" != "master" ]; then
      echo "[$BRANCH_NAME] $(cat $1)" &gt; $1
  fi
  </code></pre>
  
  <p>End result:</p>
  
  <pre><code>[ticket-45-my-new-feature-branch-description] test commit
  </code></pre>
  
  <p>What I'm trying to accomplish is output like this:</p>
  
  <pre><code>[ticket-45] test commit
  </code></pre>
  
  <p>Brownie points if we can capitalize it:</p>
  
  <pre><code>[TICKET-45] test commit
  </code></pre>
  
  <p>I would love to keep my descriptive branch names, but truncate the prepended text in commit messages. I'm sure I have to use some regex, but I really don't know how to accomplish that. I should mention that we have several projects going on at once, so branch names are different, like so:</p>
  
  <pre><code>ticket-123-branch-name
  abc-22-my-branch
  ua-11-my-feature
  </code></pre>
  
  <p>The only thing in common is the fact that I need everything before the second '-'.</p>
  
  <p>Any help is greatly appreciated!!!</p>