Skip to content

Commit a45f590

Browse files
author
Shane da Silva
committed
Rename command helper to execute
Since we have already changed the signature of this helper in a previous commit, rename it to further emphasize the difference, as well as make the method name more verb-like. Change-Id: Ie768052999d69c03943020b90eaccce9f2ecdb8b Reviewed-on: http://gerrit.causes.com/36001 Tested-by: jenkins <jenkins@causes.com> Reviewed-by: Shane da Silva <shane@causes.com>
1 parent 57706f7 commit a45f590

29 files changed

+42
-41
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Change `command` hook helper signature to accept an array of arguments
66
instead of a shell string
7+
* Rename `command` hook helper to `execute`
78
* Add support for JRuby 1.7.9 in Ruby 1.9 mode
89

910
## 0.6.3

lib/overcommit/hook/base.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def in_path?(cmd)
5151
Overcommit::Utils.in_path?(cmd)
5252
end
5353

54-
def command(cmd)
55-
Overcommit::Utils.command(cmd)
54+
def execute(cmd)
55+
Overcommit::Utils.execute(cmd)
5656
end
5757

5858
# Gets a list of staged files that apply to this hook based on its

lib/overcommit/hook/commit_msg/gerrit_change_id.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module Overcommit::Hook::CommitMsg
77
# edit the message after a prepare-commit-msg hook was run.
88
class GerritChangeId < Base
99
def run
10-
result = command([SCRIPT_LOCATION, commit_message_file])
10+
result = execute([SCRIPT_LOCATION, commit_message_file])
1111
return (result.success? ? :good : :bad), result.stdout
1212
end
1313

lib/overcommit/hook/post_checkout/bundle_check.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ def run
1515
private
1616

1717
def dependencies_changed?
18-
result = command(%w[git diff --exit-code --name-only] + [new_head, previous_head])
18+
result = execute(%w[git diff --exit-code --name-only] + [new_head, previous_head])
1919

2020
result.stdout.split("\n").any? do |file|
2121
Array(@config['include']).any? { |glob| File.fnmatch(glob, file) }
2222
end
2323
end
2424

2525
def dependencies_satisfied?
26-
command(%w[bundle check]).success?
26+
execute(%w[bundle check]).success?
2727
end
2828
end
2929
end

lib/overcommit/hook/pre_commit/author_email.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Overcommit::Hook::PreCommit
22
# Checks the format of an author's email address.
33
class AuthorEmail < Base
44
def run
5-
result = command(%w[git config --get user.email])
5+
result = execute(%w[git config --get user.email])
66
email = result.stdout.chomp
77

88
unless email =~ /#{@config['pattern']}/

lib/overcommit/hook/pre_commit/author_name.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Overcommit::Hook::PreCommit
22
# Ensures that a commit author has a name with at least first and last names.
33
class AuthorName < Base
44
def run
5-
result = command(%w[git config --get user.name])
5+
result = execute(%w[git config --get user.name])
66
name = result.stdout.chomp
77

88
unless name.split(' ').count >= 2

lib/overcommit/hook/pre_commit/bundle_check.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ def run
88
end
99

1010
# Ignore if Gemfile.lock is not tracked by git
11-
return :good if command(%w[git check-ignore] + [LOCK_FILE]).success?
11+
return :good if execute(%w[git check-ignore] + [LOCK_FILE]).success?
1212

13-
result = command(%w[bundle check])
13+
result = execute(%w[bundle check])
1414
unless result.success?
1515
return :bad, result.stdout
1616
end
1717

18-
result = command(%w[git diff --quiet --] + [LOCK_FILE])
18+
result = execute(%w[git diff --quiet --] + [LOCK_FILE])
1919
unless result.success?
2020
return :bad, "#{LOCK_FILE} is not up-to-date -- run `bundle check`"
2121
end

lib/overcommit/hook/pre_commit/coffee_lint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def run
66
return :warn, 'Run `npm install -g coffeelint`'
77
end
88

9-
result = command(%w[coffeelint --quiet] + applicable_files)
9+
result = execute(%w[coffeelint --quiet] + applicable_files)
1010
return :good if result.success?
1111
return :bad, result.stdout
1212
end

lib/overcommit/hook/pre_commit/css_lint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def run
66
return :warn, 'csslint not installed -- run `npm install -g csslint`'
77
end
88

9-
result = command(%w[csslint --quiet --format=compact] + applicable_files)
9+
result = execute(%w[csslint --quiet --format=compact] + applicable_files)
1010
output = result.stdout
1111
return (output !~ /Error - (?!Unknown @ rule)/ ? :good : :bad), output
1212
end

lib/overcommit/hook/pre_commit/haml_lint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def run
66
return :warn, 'haml-lint not installed -- run `gem install haml-lint`'
77
end
88

9-
result = command(%w[haml-lint] + applicable_files)
9+
result = execute(%w[haml-lint] + applicable_files)
1010
return :good if result.success?
1111

1212
# Keep lines from the output for files that we actually modified

lib/overcommit/hook/pre_commit/hard_tabs.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Overcommit::Hook::PreCommit
33
class HardTabs < Base
44
def run
55
# Catches hard tabs
6-
result = command(%w[grep -IHn] + ["\t"] + applicable_files)
6+
result = execute(%w[grep -IHn] + ["\t"] + applicable_files)
77
unless result.stdout.empty?
88
return :bad, "Hard tabs detected:\n#{result.stdout}"
99
end

lib/overcommit/hook/pre_commit/js_hint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def run
66
return :warn, 'jshint not installed -- run `npm install -g jshint`'
77
end
88

9-
result = command(%w[jshint] + applicable_files)
9+
result = execute(%w[jshint] + applicable_files)
1010
output = result.stdout
1111

1212
return (output.empty? ? :good : :bad), output

lib/overcommit/hook/pre_commit/jscs.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def run
77
return :warn, 'jscs not installed -- run `npm install -g jscs`'
88
end
99

10-
result = command(%w[jscs --reporter=inline] + applicable_files)
10+
result = execute(%w[jscs --reporter=inline] + applicable_files)
1111
return :good if result.success?
1212

1313
if /Config.*not found/i =~ result.stderr

lib/overcommit/hook/pre_commit/python_flake8.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def run
66
return :warn, 'flake8 not installed -- run `pip install flake8`'
77
end
88

9-
result = command(%w[flake8] + applicable_files)
9+
result = execute(%w[flake8] + applicable_files)
1010

1111
return (result.success? ? :good : :bad), result.stdout
1212
end

lib/overcommit/hook/pre_commit/rubocop.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def run
66
return :warn, 'Rubocop not installed -- run `gem install rubocop`'
77
end
88

9-
result = command(%w[rubocop --format=emacs] + applicable_files)
9+
result = execute(%w[rubocop --format=emacs] + applicable_files)
1010
return :good if result.success?
1111

1212
output = result.stdout + result.stderr

lib/overcommit/hook/pre_commit/scss_lint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def run
66
return :warn, 'scss-lint not installed -- run `gem install scss-lint`'
77
end
88

9-
result = command(%w[scss-lint] + applicable_files)
9+
result = execute(%w[scss-lint] + applicable_files)
1010
return :good if result.success?
1111

1212
# Keep lines from the output for files that we actually modified

lib/overcommit/hook/pre_commit/trailing_whitespace.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Overcommit::Hook::PreCommit
22
# Checks for trailing whitespace in files.
33
class TrailingWhitespace < Base
44
def run
5-
result = command(%w[grep -IHn \s$] + applicable_files)
5+
result = execute(%w[grep -IHn \s$] + applicable_files)
66
unless result.stdout.empty?
77
return :bad, "Trailing whitespace detected:\n#{result.stdout}"
88
end

lib/overcommit/utils.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def in_path?(cmd)
6262
# Overcommit to call other Ruby executables without requiring that they be
6363
# specified in Overcommit's Gemfile--a nasty consequence of using
6464
# `bundle exec overcommit` while developing locally.
65-
def command(args)
65+
def execute(args)
6666
with_environment 'RUBYOPT' => nil do
6767
Subprocess.spawn(args)
6868
end

spec/overcommit/hook/pre_commit/author_email_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
before do
1010
result.stub(:stdout).and_return(email)
11-
subject.stub(:command).and_return(result)
11+
subject.stub(:execute).and_return(result)
1212
end
1313

1414
context 'when user has no email' do

spec/overcommit/hook/pre_commit/author_name_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
before do
1010
result.stub(:stdout).and_return(name)
11-
subject.stub(:command).and_return(result)
11+
subject.stub(:execute).and_return(result)
1212
end
1313

1414
context 'when user has no name' do

spec/overcommit/hook/pre_commit/bundle_check_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737

3838
before do
3939
result.stub(:success? => success, :stdout => 'Bundler error message')
40-
subject.stub(:command).and_call_original
41-
subject.stub(:command).with(%w[bundle check]).and_return(result)
40+
subject.stub(:execute).and_call_original
41+
subject.stub(:execute).with(%w[bundle check]).and_return(result)
4242
end
4343

4444
context 'and bundle check exits unsuccessfully' do

spec/overcommit/hook/pre_commit/coffee_lint_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
before do
2323
result = double('result')
2424
result.stub(:success?).and_return(true)
25-
subject.stub(:command).and_return(result)
25+
subject.stub(:execute).and_return(result)
2626
end
2727

2828
it { should pass }
@@ -33,7 +33,7 @@
3333
result = double('result')
3434
result.stub(:success?).and_return(false)
3535
result.stub(:stdout)
36-
subject.stub(:command).and_return(result)
36+
subject.stub(:execute).and_return(result)
3737
end
3838

3939
it { should fail_check }

spec/overcommit/hook/pre_commit/css_lint_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
before do
2323
result = double('result')
2424
result.stub(:stdout).and_return('')
25-
subject.stub(:command).and_return(result)
25+
subject.stub(:execute).and_return(result)
2626
end
2727

2828
it { should pass }
@@ -32,7 +32,7 @@
3232
before do
3333
result = double('result')
3434
result.stub(:stdout).and_return('Error - @charset not allowed here')
35-
subject.stub(:command).and_return(result)
35+
subject.stub(:execute).and_return(result)
3636
end
3737

3838
it { should fail_check }

spec/overcommit/hook/pre_commit/haml_lint_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
before do
2323
result = double('result')
2424
result.stub(:success?).and_return(true)
25-
subject.stub(:command).and_return(result)
25+
subject.stub(:execute).and_return(result)
2626
end
2727

2828
it { should pass }
@@ -33,7 +33,7 @@
3333

3434
before do
3535
result.stub(:success?).and_return(false)
36-
subject.stub(:command).and_return(result)
36+
subject.stub(:execute).and_return(result)
3737
end
3838

3939
context 'and it reports lines that were not modified by the commit' do

spec/overcommit/hook/pre_commit/js_hint_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
before do
2323
result = double('result')
2424
result.stub(:stdout).and_return('')
25-
subject.stub(:command).and_return(result)
25+
subject.stub(:execute).and_return(result)
2626
end
2727

2828
it { should pass }
@@ -32,7 +32,7 @@
3232
before do
3333
result = double('result')
3434
result.stub(:stdout).and_return('Undefined variable')
35-
subject.stub(:command).and_return(result)
35+
subject.stub(:execute).and_return(result)
3636
end
3737

3838
it { should fail_check }

spec/overcommit/hook/pre_commit/jscs_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
result = double('result')
2424
result.stub(:success? => false,
2525
:stderr => 'Configuration file some-path/.jscs.json was not found.')
26-
subject.stub(:command).and_return(result)
26+
subject.stub(:execute).and_return(result)
2727
end
2828

2929
it { should warn }
@@ -34,7 +34,7 @@
3434

3535
before do
3636
result.stub(:success? => false, :stderr => '')
37-
subject.stub(:command).and_return(result)
37+
subject.stub(:execute).and_return(result)
3838
end
3939

4040
context 'and it reports lines that were not modified by the commit' do

spec/overcommit/hook/pre_commit/python_flake8_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
result = double('result')
2424
result.stub(:success?).and_return(true)
2525
result.stub(:stdout)
26-
subject.stub(:command).and_return(result)
26+
subject.stub(:execute).and_return(result)
2727
end
2828

2929
it { should pass }
@@ -34,7 +34,7 @@
3434
result = double('result')
3535
result.stub(:success?).and_return(false)
3636
result.stub(:stdout)
37-
subject.stub(:command).and_return(result)
37+
subject.stub(:execute).and_return(result)
3838
end
3939

4040
it { should fail_check }

spec/overcommit/hook/pre_commit/rubocop_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
before do
2323
result = double('result')
2424
result.stub(:success?).and_return(true)
25-
subject.stub(:command).and_return(result)
25+
subject.stub(:execute).and_return(result)
2626
end
2727

2828
it { should pass }
@@ -33,7 +33,7 @@
3333

3434
before do
3535
result.stub(:success?).and_return(false)
36-
subject.stub(:command).and_return(result)
36+
subject.stub(:execute).and_return(result)
3737
end
3838

3939
context 'and it reports lines that were not modified by the commit' do

spec/overcommit/hook/pre_commit/scss_lint_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
before do
2323
result = double('result')
2424
result.stub(:success?).and_return(true)
25-
subject.stub(:command).and_return(result)
25+
subject.stub(:execute).and_return(result)
2626
end
2727

2828
it { should pass }
@@ -33,7 +33,7 @@
3333

3434
before do
3535
result.stub(:success?).and_return(false)
36-
subject.stub(:command).and_return(result)
36+
subject.stub(:execute).and_return(result)
3737
end
3838

3939
context 'and it reports lines that were not modified by the commit' do

0 commit comments

Comments
 (0)