Last active
          March 20, 2017 09:37 
        
      - 
      
 - 
        
Save isRuslan/8deabca8d41d14fbcae4837fb802e635 to your computer and use it in GitHub Desktop.  
    .git/hooks/commit-msg
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/sh | |
| # | |
| # Automatically add branch name and branch description to every commit message except merge commit. | |
| # | |
| COMMIT_EDITMSG=$1 | |
| addBranchName() { | |
| BRANCH=$(git branch | grep '*' | sed 's/* //') | |
| NAME=$(echo "$BRANCH" | sed -E 's/([A-Z]+-[0-9]+(--[A-Z]+-[0-9]+)?).*/\1/') | |
| DESCRIPTION=$(git config branch."$BRANCH".description) | |
| echo "$NAME: $(cat $COMMIT_EDITMSG)" > $COMMIT_EDITMSG | |
| if [ -n "$DESCRIPTION" ] | |
| then | |
| echo "" >> $COMMIT_EDITMSG | |
| echo $DESCRIPTION >> $COMMIT_EDITMSG | |
| fi | |
| } | |
| MERGE=$(cat $COMMIT_EDITMSG|grep -i 'merge'|wc -l) | |
| if [ $MERGE -eq 0 ] ; then | |
| addBranchName | |
| fi | |
| echo "v4" >> $COMMIT_EDITMSG | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment