Skip to content

Instantly share code, notes, and snippets.

@ilicfilip
Last active November 22, 2019 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ilicfilip/7bddee81ab019bf6180f0eca053b473d to your computer and use it in GitHub Desktop.
Save ilicfilip/7bddee81ab019bf6180f0eca053b473d to your computer and use it in GitHub Desktop.
if [ $# -lt 1 ]; then
echo "------------------------"
echo "usage: $0 \$1"
echo " \$1: Git branch to checkout."
echo "usage: $0 tag \$2"
echo " \$2: Tag to checkout."
echo "usage: $0 tag \$2 update_version"
echo " \$2: Tag to checkout."
echo " : Update WP DB version."
echo "usage: $0 date \$2 \$3"
echo " \$2: Branch to checkout"
echo " \$3: Date: YYYY-MM-DD HH:MM"
echo "------------------------"
exit 1
fi
Avada_Path='/Applications/MAMP/htdocs/avada/wp-content/themes/Avada/';
FB_Path='/Applications/MAMP/htdocs/avada/wp-content/plugins/Fusion-Builder/';
FC_Path='/Applications/MAMP/htdocs/avada/wp-content/plugins/Fusion-Core/';
FL_Path='/Applications/MAMP/htdocs/avada/wp-content/plugins/Fusion-Library/';
if [ 'tag' == $1 ]
then
branch_avada=$2;
branch_whole=${branch_avada:0:1};
branch_decimal=${branch_avada:1};
branch_fb="$(($branch_whole-4))$branch_decimal";
branch_fc="$(($branch_whole-2))$branch_decimal";
branch_fl="$(($branch_whole-4))$branch_decimal";
update_version=0;
if [ "$#" == 3 ] && [ 'update_version' == $3 ]
then
update_version=1;
fi
elif [ 'date' == $1 ]
then
branch_avada=$2;
branch_fb=$2;
branch_fc=$2;
branch_fl=$2;
date=$3;
else
branch_avada=$1;
branch_fb=$1;
branch_fc=$1;
branch_fl=$1;
fi
if [ 'dev' == $branch_avada ]
then
branch_avada='development';
branch_fb='development';
branch_fc='development';
branch_fl='development';
fi
printf "Switching to Avada repo...\n";
cd $Avada_Path;
if [ 'date' == $1 ]
then
branch_avada=`git rev-list -n 1 --first-parent --before="$date" $branch_avada`;
fi
git stash && git checkout $branch_avada;
if [ 'tag' != $1 ] && [ 'date' != $1 ]
then
git pull;
elif [ 'tag' == $1 ]
then
if [ 1 == $update_version ]
then
printf "Updating Avada version...\n";
wp option update avada_version $branch_avada
wp option update fusion_builder_version $branch_fb
fi
fi
printf "\n";
printf "Switching to Fusion Builder repo...\n";
cd $FB_Path;
if [ 'date' == $1 ]
then
branch_fb=`git rev-list -n 1 --first-parent --before="$date" $branch_fb`;
fi
git stash && git checkout $branch_fb;
if [ 'tag' != $1 ] && [ 'date' != $1 ]
then
git pull;
fi
printf "\n";
printf "Switching to Fusion Library repo...\n";
cd $FL_Path;
if [ 'date' == $1 ]
then
branch_fl=`git rev-list -n 1 --first-parent --before="$date" $branch_fl`;
fi
git stash && git checkout $branch_fl;
if [ 'tag' != $1 ] && [ 'date' != $1 ]
then
git pull;
fi
printf "\n";
printf "Switching to Fusion Core repo...\n";
cd $FC_Path;
if [ 'date' == $1 ]
then
branch_fc=`git rev-list -n 1 --first-parent --before="$date" $branch_fc`;
fi
git stash && git checkout $branch_fc;
if [ 'tag' != $1 ] && [ 'date' != $1 ]
then
git pull;
fi
printf "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment