Advertisement
Guest User

Untitled

a guest
May 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # Automatically adds branch name and branch description to every commit
  4. # message.
  5. #
  6. COMMIT_EDITMSG=$1
  7.  
  8. addBranchName() {
  9. NAME=$(git branch | grep '*' | sed 's/* //' | grep -Eo '[0-9]+')
  10. DESCRIPTION=$(git config branch."$NAME".description)
  11. if [ -n "$NAME" ]
  12. then
  13. echo "Issue #$NAME - $(cat $COMMIT_EDITMSG)" > $COMMIT_EDITMSG
  14. if [ -n "$DESCRIPTION" ]
  15. then
  16. echo "" >> $COMMIT_EDITMSG
  17. echo $DESCRIPTION >> $COMMIT_EDITMSG
  18. fi
  19. fi
  20. }
  21.  
  22. MERGE=$(cat $COMMIT_EDITMSG|grep -i 'merge'|wc -l)
  23.  
  24. if [ $MERGE -eq 0 ] ; then
  25. addBranchName
  26. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement