Skip to content

Instantly share code, notes, and snippets.

@kevinrutherford
Created March 6, 2015 06:51
Show Gist options
  • Save kevinrutherford/a5cbfce754156b2fa00c to your computer and use it in GitHub Desktop.
Save kevinrutherford/a5cbfce754156b2fa00c to your computer and use it in GitHub Desktop.
Sometimes I need to figure out which gem update broke my build.
#! /bin/sh
#
GEMFILE=Gemfile.lock
[ $# -lt 1 ] && { echo "Usage: $0 cmd" >&2; return 1; }
[ -r $GEMFILE ] || { echo "Cannot find $GEMFILE" >&2; return 1; }
cmd="$@"
eval $cmd || { echo "\`$*\` fails!" >&2; return 1; }
gems=`cat $GEMFILE | sed -n '/specs\:/,/^$/p' | sed 1d | awk '{print $1}' | sort | uniq`
num_gems=`echo $gems | wc -w`
[ $num_gems -gt 5 ] && { echo; echo "$(tput setaf 3)You have $num_gems gems; this may take a while!$(tput sgr 0)"; echo; }
for gem in $gems; do
echo "Trying $gem ..."
bundle update $gem && {
eval $cmd || bad_gems="$bad_gems $gem"
}
git checkout $GEMFILE
done
if [ z$bad_gems -eq z ]; then
echo "$(tput setaf 2)All of your gems update ok$(tput sgr 0)"
else
echo "$(tput setaf 1)The following gems fail: $bad_gems$(tput sgr 0)"
return 2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment