Skip to content

Instantly share code, notes, and snippets.

@r3ap3r2004
Created January 1, 2012 16:42
Show Gist options
  • Save r3ap3r2004/1547737 to your computer and use it in GitHub Desktop.
Save r3ap3r2004/1547737 to your computer and use it in GitHub Desktop.
TRACKS CHANGES TO PARTS OF SPREE SINCE A GIVEN BRANCH
#!/usr/bin/env zsh
# 1304046900 TRACKS CHANGES TO PARTS OF SPREE SINCE A GIVEN BRANCH
old_branch_or_commit="29e3d4f707bdb047a6fabc2543247139027b06fb"
parts=(
config/locales/en.yml
core/app/views
)
# Exit on failure
#
set -e
cd tmp
git clone git://github.com/spree/spree.git
cd spree
if output=$(git diff --exit-code --name-status "$old_branch_or_commit" HEAD -- "${parts[@]}"); 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 "You are now at: $(git rev-parse HEAD)"
fi
cd ..
rm -rf spree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment