Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- BRANCH_NAME=$(git symbolic-ref --short HEAD)
- BRANCH_ADDED=$(grep -c "\[$BRANCH_NAME\]" $1)
- ## if branch was not manually added and BRANCH_NAME is not empty + starts with "ch"
- if ! [[ $BRANCH_ADDED -ge 1 ]] && [ -n $BRANCH_NAME ] && [[ $BRANCH_NAME =~ ^ch.* ]]; then
- # remove everything after - or / (ch122/my-branch => ch122)
- BRANCH_NAME="${BRANCH_NAME%%[-/]*}"
- sed -i.bak -e "1s/^/[$BRANCH_NAME] /" $1
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement