Created
March 19, 2015 14:35
-
-
Save greyblake/da0a59a37a6299fb91d3 to your computer and use it in GitHub Desktop.
rubocop-detect
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
# Finds ruby files that was changed in HEAD against passed branch | |
# and run rubocop with them. It's supposed to help to detect | |
# rubocop offenses introduced by YOU. | |
# | |
# Examle: | |
# rubocop-detect develop | |
function rubocop-detect(){ | |
local branch=${1:-master} | |
echo -e "\e[1mCOMPARING:\e[0m" | |
echo -e " git diff $branch..HEAD\n" | |
local changed_ruby_files=$(git diff --name-only $branch HEAD | grep .rb$) | |
for file in $changed_ruby_files; do | |
if [ -e $file ]; then | |
local existing_ruby_files="${existing_ruby_files} ${file}" | |
fi | |
done | |
echo -e "\e[1mCHANGED RUBY FILES:\e[0m" | |
for file in $existing_ruby_files; do | |
echo " $file" | |
done | |
echo -e "\n" | |
echo -e "\e[1mRUBOCOP:\e[0m" | |
rubocop $existing_ruby_files | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it doesn't work !!!