Created
March 14, 2012 01:06
-
-
Save r3ap3r2004/2033128 to your computer and use it in GitHub Desktop.
TRACKS CHANGES TO PARTS OF SPREE SINCE A GIVEN COMMIT
This file contains 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 PARTS OF SPREE SINCE A GIVEN COMMIT | |
# To be placed in the root of your app. | |
old_commit="32483802d823e92c0746d080217870dd48f49307" | |
parts=( | |
core/app/assets/javascripts/store/checkout.js | |
core/app/helpers/spree/base_helper.rb | |
core/app/helpers/spree/checkout_helper.rb | |
core/app/views/spree | |
core/config/locales/en.yml | |
core/lib/generators/spree/install/templates | |
) | |
# Exit on failure | |
# | |
set -e | |
git clone git://github.com/spree/spree.git tmp/spree_check | |
cd tmp/spree_check | |
if output=$(git diff --exit-code --name-status $old_commit HEAD -- $parts); 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 "You are now at: $(git rev-parse HEAD)" | |
fi | |
cd ../../ | |
rm -r tmp/spree_check |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment