Skip to content

Instantly share code, notes, and snippets.

@greyblake
Created March 19, 2015 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greyblake/da0a59a37a6299fb91d3 to your computer and use it in GitHub Desktop.
Save greyblake/da0a59a37a6299fb91d3 to your computer and use it in GitHub Desktop.
rubocop-detect
# 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
}
@aaeabdo
Copy link

aaeabdo commented Mar 31, 2015

it doesn't work !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment