Created
April 28, 2015 09:17
-
-
Save alkuzad/dd729aca36a810892772 to your computer and use it in GitHub Desktop.
Rubocop check only files that are changed
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
# 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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is already bash script, bashrc is for configuration, not whole scripts...