Last active
August 29, 2015 13:56
-
-
Save dlanner/8790027 to your computer and use it in GitHub Desktop.
Bash script to help switch between different revision control branches in Vagrant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Usage: ./vagrant_switch_branch 1.0 | |
| # export APP_ROOT=/path/to/my_app | |
| # export CURRENT_BRANCH=$APP_ROOT/current_branch | |
| if [ ! -n "$APP_ROOT" ]; then | |
| echo "Error: APP_ROOT is not defined" | |
| exit 1 | |
| elif [ ! -n "$CURRENT_BRANCH" ]; then | |
| echo "Error: CURRENT_BRANCH is not defined" | |
| exit 1 | |
| else | |
| BRANCH=$1 | |
| if [ ! -d $APP_ROOT/$BRANCH ]; then | |
| echo "Error: $APP_ROOT/$BRANCH does not exist" | |
| exit 1 | |
| else | |
| if [ -L $CURRENT_BRANCH ]; then | |
| rm $CURRENT_BRANCH | |
| fi | |
| ln -s $APP_ROOT/$BRANCH $CURRENT_BRANCH | |
| fi | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment