Skip to content

Instantly share code, notes, and snippets.

@greyblake
Created March 19, 2015 14:35
Show Gist options
  • Select an option

  • Save greyblake/da0a59a37a6299fb91d3 to your computer and use it in GitHub Desktop.

Select an option

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

aaeabdo commented Mar 31, 2015

Copy link
Copy Markdown

it doesn't work !!!

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