Created
October 1, 2013 15:32
-
-
Save mueschm/6780322 to your computer and use it in GitHub Desktop.
Load branches of git repo into seperate folders of website
This file contains 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
contains() { | |
string="$1" | |
substring="$2" | |
if test "${string#*$substring}" != "$string" | |
then | |
return 0 | |
else | |
return 1 | |
fi | |
} | |
updateBranch() { | |
fullBranch="$1" | |
branchName=${fullBranch:15} | |
echo "Found branch $branchName. Attempting to update." | |
echo git checkout -b $branchName origin/$branchName | |
git checkout $branchName | |
update=`git pull origin $branchName` | |
numrowsupdate=`echo -e "$branches" | wc -l` | |
lastlineupdate=`echo -e "$update" | head -$numrowsupdate | tail -1` | |
if contains "$lastlineupdate" "up-to-date" && [ -d "/var/www/html/$branchName" ] | |
then | |
return | |
fi | |
echo "Updating branch $branchName on website" | |
rm -rf /var/www/hhtml/$branchName | |
echo /var/www/html/$branchName | |
mkdir /var/www/html/$branchName | |
cp -r ./* /var/www/html/$branchName | |
} | |
while [ 1 ]; do | |
git fetch origin | |
branches=`git branch -a` | |
numrows=`echo -e "$branches" | wc -l` | |
for i in `seq 2 $numrows`; do | |
branch=`echo -e "$branches" | head -$i | tail -1` | |
contains $branch "remotes/origin/" && updateBranch $branch | |
done | |
sleep 30 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment