Guest User

Untitled

a guest
Feb 21st, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # This way you can customize which branches should be skipped when
  4. # prepending commit message.
  5. if [ -z "$BRANCHES_TO_SKIP" ]; then
  6. BRANCHES_TO_SKIP=(master develop test)
  7. fi
  8.  
  9. BRANCH_NAME=$(git symbolic-ref --short HEAD)
  10. BRANCH_NAME="${BRANCH_NAME##*/}"
  11.  
  12. BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$")
  13. BRANCH_IN_COMMIT=$(grep -c "$BRANCH_NAME" $1)
  14.  
  15. if [ -n "$BRANCH_NAME" ] && ! [[ $BRANCH_EXCLUDED -eq 1 ]] && ! [[ $BRANCH_IN_COMMIT -ge 1 ]]; then
  16. sed -i.bak -e "1s/^/$BRANCH_NAME /" $1
  17. fi
Add Comment
Please, Sign In to add comment