Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #!/bin/sh
  2. # Place me in .git/hooks/post-checkout
  3.  
  4. # Gets name from previous branch
  5. PREVIOUS_BRANCH=$(git name-rev --name-only $1)
  6. # Gets name from current branch
  7. CURRENT_BRANCH=$(git name-rev --name-only $2)
  8.  
  9. if [ "${PREVIOUS_BRANCH}" != "${CURRENT_BRANCH}" ]; then
  10. echo "Coming from ${PREVIOUS_BRANCH} to ${CURRENT_BRANCH}"
  11. export PREVIOUS_NAME=$(basename `pwd`)_${PREVIOUS_BRANCH}
  12. export PROJECT_NAME=$(basename `pwd`)_${CURRENT_BRANCH}
  13. docker-compose -p ${PREVIOUS_NAME} stop
  14. docker-compose -p ${PROJECT_NAME} up -d
  15. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement