Skip to content

Instantly share code, notes, and snippets.

@saily
Last active August 29, 2015 14:07
Show Gist options
  • Save saily/df06d339ebf415b0a44f to your computer and use it in GitHub Desktop.
Save saily/df06d339ebf415b0a44f to your computer and use it in GitHub Desktop.
Update buildout including all sources in src dir
#!/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
@saily
Copy link
Author

saily commented Oct 22, 2014

symlink into your buildout root and run it using ./update.sh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment