Skip to content

Instantly share code, notes, and snippets.

@monkseal
Created September 25, 2018 16:03
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 monkseal/d5cb4a8a28ecf4b4b4b1919af896040e to your computer and use it in GitHub Desktop.
Save monkseal/d5cb4a8a28ecf4b4b4b1919af896040e to your computer and use it in GitHub Desktop.
Rubocop change
desc 'Run RuboCop on the app and lib directories based on git diff'
Rubocop::RakeTask.new('rubocop') do |task|
cmd = 'git diff --name-only --diff-filter=ACMRTUXB ' \
'$(git merge-base HEAD flux) ' \
'| egrep \'\.rake$|\.rb$\''
diff = `#{cmd}`
# always include this file, if the patterns is empty it run everything
patterns = ['lib/tasks/ci.rake']
patterns += diff.split("\n")
task.patterns = patterns.reject do |pattern|
RUBOCOP_IGNORE.any? { |ignore_exp| ignore_exp.match(pattern) }
end
task.fail_on_error = true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment