Skip to content

Instantly share code, notes, and snippets.

@alkuzad
Created April 28, 2015 09:17
Show Gist options
  • Save alkuzad/dd729aca36a810892772 to your computer and use it in GitHub Desktop.
Save alkuzad/dd729aca36a810892772 to your computer and use it in GitHub Desktop.
Rubocop check only files that are changed
# Needs showlinennum in ~/bin folder of user, change it to some more general
# solution if you have showlinenum in path
if [ "$1" == "" ];then
rev="HEAD"
else
rev="$1"
fi
if [ -e ~/bin/showlinenum.awk ]; then
git diff $rev --diff-filter=ACM --name-only | while read file;do rubocop $file | awk "/$(echo "$(echo $file | tr "/" '.'):("$((git diff -U0 HEAD $file | ~/bin/showlinenum.awk | awk -F':' '/^[0-9]+:/ {print $1}' | tr '\n' '|') | rev | cut -c 2- | rev)")")/ {print}";done | grep -v " C:"
else
echo "~/bin/showlinenum.awk does not exist. Install it from https://github.com/jay/showlinenum"
fi
@alkuzad
Copy link
Author

alkuzad commented Jan 1, 2023

It is already bash script, bashrc is for configuration, not whole scripts...

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