Skip to content

Instantly share code, notes, and snippets.

@mipearson
Last active July 7, 2018 13:26
Show Gist options
  • Save mipearson/fdd2f4efbc762373206d to your computer and use it in GitHub Desktop.
Save mipearson/fdd2f4efbc762373206d to your computer and use it in GitHub Desktop.
Run Rubocop against all files that are different from upstream's master
#!/usr/bin/env ruby
changed = `git diff --numstat origin/master | awk '{ print $3 }' | grep -E '(\\.rb|\\.rake)$'`
changed = changed.split("\n").select { |c| File.exist?(c) }
if changed.length > 0
system "rubocop #{ARGV.join(' ')} #{changed.join(' ')}"
else
puts "No changes."
end
@mipearson
Copy link
Author

(ps: could be 100% bash, but I don't know how to filter a list of files to only include the ones that still exist)

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