Skip to content

Commit

Permalink
improved extra_grep
Browse files Browse the repository at this point in the history
  • Loading branch information
mpapis committed Sep 13, 2014
1 parent 13618e4 commit ac02861
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/plugins/pre_commit/checks/before_all.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def files_filter(staged_files)
end

def extra_grep
%w{| grep -v //}
%w{-v //}
end

def message
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/pre_commit/checks/console_log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def files_filter(staged_files)
end

def extra_grep
%w{| grep -v //}
%w{-v //}
end

def message
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/pre_commit/checks/gemfile_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def pattern
end

def extra_grep
%w{| grep -v #}
%w{-v #}
end

def self.description
Expand Down
2 changes: 1 addition & 1 deletion lib/pre-commit/checks/grep.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def call(staged_files)
staged_files = files_filter(staged_files)
return if staged_files.empty?
args = grep + [pattern] + staged_files
args << extra_grep if !extra_grep.nil? and extra_grep != ""
args += ["|", "grep"] + extra_grep if !extra_grep.nil? and !extra_grep.empty?
errors = execute(args, success_status: false)
errors and "#{message}#{errors}"
end
Expand Down
2 changes: 1 addition & 1 deletion test/unit/pre-commit/checks/grep_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

it "respects extra_grep" do
subject.instance_variable_set(:@pattern, "test")
subject.instance_variable_set(:@extra_grep, "| grep -v test")
subject.instance_variable_set(:@extra_grep, %w{-v test})
subject.call([fixture_file('file_with_nb_space.rb')]).must_equal(nil)
end

Expand Down

0 comments on commit ac02861

Please sign in to comment.