Skip to content

Instantly share code, notes, and snippets.

View kiran's full-sized avatar

Kiran Bhattaram kiran

View GitHub Profile
@kiran
kiran / rubocop_pre_commit_hook
Last active February 9, 2016 14:41 — forked from mpeteuil/rubocop_pre_commit_hook
forked pre-commit hook for changed ruby files. (whitespace sensitivity in the regex was borking selection)
#!/usr/bin/env ruby
require 'english'
require 'rubocop'
ADDED_OR_MODIFIED = /^\s*(A|AM|M)/.freeze
changed_files = `git status --porcelain`.split(/\n/).
select { |file_name_with_status|
file_name_with_status =~ ADDED_OR_MODIFIED