Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. BRANCH_NAME=$(git symbolic-ref --short HEAD)
  4. BRANCH_ADDED=$(grep -c "\[$BRANCH_NAME\]" $1)
  5.  
  6. ## if branch was not manually added and BRANCH_NAME is not empty + starts with "ch"
  7. if ! [[ $BRANCH_ADDED -ge 1 ]] && [ -n $BRANCH_NAME ] && [[ $BRANCH_NAME =~ ^ch.* ]]; then
  8. # remove everything after - or / (ch122/my-branch => ch122)
  9. BRANCH_NAME="${BRANCH_NAME%%[-/]*}"
  10.  
  11. sed -i.bak -e "1s/^/[$BRANCH_NAME] /" $1
  12. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement