Guest User

Untitled

a guest
Feb 13th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  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
Add Comment
Please, Sign In to add comment