SHARE
TWEET

Untitled

a guest Jun 19th, 2017 41 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
Top