Skip to content

Instantly share code, notes, and snippets.

@r3ap3r2004
Created January 1, 2012 16:43
Show Gist options
  • Save r3ap3r2004/1547740 to your computer and use it in GitHub Desktop.
Save r3ap3r2004/1547740 to your computer and use it in GitHub Desktop.
TRACKS CHANGES TO RAILS' APP SKELETON SINCE A GIVEN VERSION
#!/usr/bin/env zsh
# 1304046900 TRACKS CHANGES TO RAILS' APP SKELETON SINCE A GIVEN VERSION
old_version="3.1.1"
# Exit on failure
#
set -e
cd tmp
gem uninstall rails
gem install rails -v "$old_version"
rails new skeleton_check
cd skeleton_check
git init
git add *
git checkout -b "$old_version"
git commit --allow-empty-message
rm -rf *
cd ..
gem update rails
rails new skeleton_check
cd skeleton_check
git add *
git checkout master
git commit --allow-empty-message
if output=$(git diff --exit-code --name-status "$old_version" HEAD); then
echo "No changes"
else
# Group name statuses
#
while read -r line; do
case $line in
(M*) modified+=("$line") ;;
(A*) added+=("$line") ;;
(D*) deleted+=("$line") ;;
esac
done <<< "$output"
# Display groups
#
if [[ -n $modified ]]; then
print -l -- "${modified[@]}"
echo
fi
if [[ -n $added ]]; then
print -l -- "${added[@]}"
echo
fi
if [[ -n $deleted ]]; then
print -l -- "${deleted[@]}"
echo
fi
echo "Current version: $(rails -v)"
fi
cd ..
rm -rf skeleton_check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment