Last active
August 29, 2015 14:07
-
-
Save saily/df06d339ebf415b0a44f to your computer and use it in GitHub Desktop.
Update buildout including all sources in src dir
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
#!/bin/sh | |
spinner() { | |
# thanks to: http://fitnr.com/showing-a-bash-spinner.html | |
local pid=$1 | |
local delay=0.075 | |
local spinstr='|/-\' | |
local infotext=$2 | |
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do | |
local temp=${spinstr#?} | |
printf "[ %c ] %s" "$spinstr" "$infotext" | |
local spinstr=$temp${spinstr%"$temp"} | |
sleep $delay | |
printf "\b\b\b\b\b\b\b" | |
for i in $(seq 1 ${#infotext}); do | |
printf "\b" | |
done | |
done | |
printf " \b\b\b\b" | |
} | |
function update { | |
if [ ! -d $1/.git ]; then | |
echo "[ \033[0;33mSKIP\033[0m ] $1 is not a git repository." | |
exit 1 | |
fi | |
cd $1 | |
DIRTY=`git status|grep 'modified:'` | |
if [ ! -z "$DIRTY" ]; then | |
git stash 1>/dev/null | |
echo "- Stashed local changes for $1." | |
fi | |
git fetch --all 1>/dev/null & | |
spinner $! "Fetching repository... " | |
git pull --rebase=preserve 2>/dev/null | |
if [ ! -z "$DIRTY" ]; then | |
git stash pop 1>/dev/null | |
echo "- Restored local changes for $1." | |
fi | |
echo "[ \033[0;32mOK\033[0m ] Rebased $1." | |
} | |
DIR=`pwd` | |
for REPOS in `ls $DIR/src`; do | |
update $DIR/src/$REPOS | |
done | |
cd $DIR | |
update $DIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
symlink into your buildout root and run it using
./update.sh
.