Created
March 14, 2012 01:06
-
-
Save r3ap3r2004/2033130 to your computer and use it in GitHub Desktop.
TRACKS CHANGES TO RAILS' APP SKELETON SINCE A GIVEN VERSION
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
#!/usr/bin/env zsh | |
# 1304046900 TRACKS CHANGES TO RAILS' APP SKELETON SINCE A GIVEN VERSION | |
# To be placed in the root of your app. | |
old_version="3.1.3" | |
# Exit on failure | |
# | |
set -e | |
gem uninstall rails | |
gem install rails -v $old_version | |
rails new tmp/skeleton_check | |
cd tmp/skeleton_check | |
git init | |
git add * | |
git checkout -b $old_version | |
git commit --allow-empty-message | |
rm -r * | |
cd ../../ | |
gem update rails | |
rails new tmp/skeleton_check | |
cd tmp/skeleton_check | |
git add * | |
git checkout master | |
git commit --allow-empty-message | |
if output=$(git diff --exit-code --name-status $old_version HEAD); then | |
print "No changes" | |
else | |
# Group name statuses | |
# | |
while read -r flag file; do | |
case $flag in | |
(M*) modified+=($file) ;; | |
(A*) added+=($file) ;; | |
(D*) deleted+=($file) ;; | |
esac | |
done <<< $output | |
# Display groups | |
# | |
if [[ -n $modified ]]; then | |
print -f "M %s\n" $modified | |
echo | |
fi | |
if [[ -n $added ]]; then | |
print -f "A %s\n" $added | |
echo | |
fi | |
if [[ -n $deleted ]]; then | |
print -f "D %s\n" $deleted | |
echo | |
fi | |
print -n "Show full git-diff of modified files? (Y/n) " | |
if read -q; then | |
git diff $old_commit HEAD -- $modified | ruby -pe 'puts "\n#########" if /^diff/ && $. > 1' | less | |
echo | |
fi | |
print "Current version: $(rails -v)" | |
fi | |
cd ../../ | |
rm -r tmp/skeleton_check |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment