daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # Include any branches for which you wish to disable this script
  4. if [ -z "$BRANCHES_TO_SKIP" ]; then
  5.   BRANCHES_TO_SKIP=(master develop test)
  6. fi
  7.  
  8. # Get the current branch name and check if it is excluded
  9. BRANCH_NAME=$(git symbolic-ref --short HEAD)
  10. BRANCH_NAME="${BRANCH_NAME##*/}"
  11. BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$")
  12. BRANCH_IN_COMMIT=$(grep -c "$BRANCH_NAME\:" $1)
  13.  
  14. # If it isn't excluded, prepend the trimmed branch identifier to the given message
  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
RAW Paste Data
Top