Last active
August 29, 2015 14:22
-
-
Save andrewhamon/23724158d436400c60c2 to your computer and use it in GitHub Desktop.
Rubodiff! Diffs the rubocop results of your current branch with the results of develop
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
#!/bin/bash | |
GREEN='\033[0;32m' | |
# The ampersand at the end of this line makes this command run in the background... | |
rubocop --format simple --out ~/rubocop_results_current_branch.txt & | |
# ...while all this runs in the foreground... | |
mkdir -p ~/rubodiff_temp | |
rm -rf ~/rubodiff_temp/* | |
git archive develop | tar -x -C ~/rubodiff_temp | |
rubocop --format simple --out ~/rubocop_results_develop.txt ~/rubodiff_temp | |
# Normalize the filenames that rubocop prints | |
sed -E -i '' 's/\/Users\/[^\/]+\/rubodiff_temp\///g' ~/rubocop_results_develop.txt | |
# ...and this waits until everything is done... | |
wait | |
# ...and finally a diff is printed. | |
{ | |
# Hack to prevent annoying copyright info from being printed | |
colordiff -U0 -F "==" ~/rubocop_results_develop.txt ~/rubocop_results_current_branch.txt | tee ~/rubodiff_results.txt | |
} &> /dev/null | |
cat ~/rubodiff_results.txt | |
if [[ ! -s ~/rubodiff_results.txt ]] ; then | |
echo -e "${GREEN}There were no changes in rubocop." | |
fi ; | |
# Cleanup | |
rm ~/rubocop_results_current_branch.txt | |
rm ~/rubocop_results_develop.txt | |
rm ~/rubodiff_results.txt | |
rm -rf ~/rubodiff_temp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install
brew install colordiff
chmod +x /path/to/rubodiff
/path/to/rubodiff
Sample output
Its just a diff between the two outputs of rubocop for the different branches.