Skip to content

Commit 1f51f11

Browse files
committedJul 28, 2014
Deprecate :bad status in favor of :fail
This naming convention was a holdover from very early on in Overcommit's history. However, much of the language used in Overcommit (e.g. the displayed output from the actual run, or the `fail_hook` matcher in specs) uses the verb `fail` instead of the adjective `bad`. We would like to standardize on using verbs going forward. Since there are currently custom hooks in the wild that are written to return `:bad`, we'll simply display an deprecation message for now that warns of the impending removal of this term. Change-Id: I6cbcce55e04d26bd6215449fb3427b135ab50099 Reviewed-on: http://gerrit.causes.com/40974 Tested-by: jenkins <jenkins@causes.com> Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
1 parent ec35a52 commit 1f51f11

32 files changed

+51
-40
lines changed
 

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Fix `overcommit-hook` auto-updating not passing original arguments to
99
updated hook
1010
* Display message when `overcommit-hook` file is automatically updated
11+
* Deprecate `:bad` status in favor of `:fail`
1112

1213
## 0.14.1
1314

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ module Overcommit::Hook::PreCommit
192192
end
193193
end
194194

195-
return :bad, errors.join("\n") if errors.any?
195+
return :fail, errors.join("\n") if errors.any?
196196

197197
:good
198198
end

‎lib/overcommit/hook/commit_msg/gerrit_change_id.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def run
1212
result = execute([SCRIPT_LOCATION, commit_message_file])
1313
return :good if result.success?
1414

15-
[:bad, result.stdout]
15+
[:fail, result.stdout]
1616
end
1717
end
1818
end

‎lib/overcommit/hook/pre_commit/author_email.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ def run
66
email = result.stdout.chomp
77

88
unless email =~ /#{@config['pattern']}/
9-
return :bad, "Author has an invalid email address: '#{email}'\n" \
10-
'Set your email with ' \
11-
'`git config --global user.email your_email@example.com`'
9+
return :fail,
10+
"Author has an invalid email address: '#{email}'\n" \
11+
'Set your email with ' \
12+
'`git config --global user.email your_email@example.com`'
1213
end
1314

1415
:good

‎lib/overcommit/hook/pre_commit/author_name.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ def run
66
name = result.stdout.chomp
77

88
unless name.split(' ').count >= 2
9-
return :bad, 'Author must have at least first and last name, but ' \
10-
"was: '#{name}'.\nSet your name with " \
11-
"`git config --global user.name 'Your Name'`"
9+
return :fail,
10+
"Author must have at least first and last name, but was: #{name}." \
11+
"\nSet your name with `git config --global user.name 'Your Name'`"
1212
end
1313

1414
:good

‎lib/overcommit/hook/pre_commit/berksfile_check.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def run
1515

1616
result = execute(%w[berks list --quiet])
1717
unless result.success?
18-
return :bad, result.stderr
18+
return :fail, result.stderr
1919
end
2020

2121
:good

‎lib/overcommit/hook/pre_commit/brakeman.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def run
1010
applicable_files)
1111
return :good if result.success?
1212

13-
[:bad, result.stdout]
13+
[:fail, result.stdout]
1414
end
1515
end
1616
end

‎lib/overcommit/hook/pre_commit/bundle_check.rb

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

1616
result = execute(%w[bundle check])
1717
unless result.success?
18-
return :bad, result.stdout
18+
return :fail, result.stdout
1919
end
2020

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

2626
:good

‎lib/overcommit/hook/pre_commit/chamber_security.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def run
99
result = execute(%w[chamber secure --echo --files] + applicable_files)
1010

1111
return :good if result.stdout.empty?
12-
[:bad, "These settings appear to need to be secured but were not: #{result.stdout}"]
12+
[:fail, "These settings appear to need to be secured but were not: #{result.stdout}"]
1313
end
1414
end
1515
end

‎lib/overcommit/hook/pre_commit/coffee_lint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def run
99
result = execute(%w[coffeelint --quiet] + applicable_files)
1010
return :good if result.success?
1111

12-
[:bad, result.stdout]
12+
[:fail, result.stdout]
1313
end
1414
end
1515
end

‎lib/overcommit/hook/pre_commit/css_lint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def run
99
result = execute(%w[csslint --quiet --format=compact] + applicable_files)
1010
return :good if result.stdout !~ /Error - (?!Unknown @ rule)/
1111

12-
[:bad, result.stdout]
12+
[:fail, result.stdout]
1313
end
1414
end
1515
end

‎lib/overcommit/hook/pre_commit/go_lint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def run
1010
# Unfortunately the exit code is always 0
1111
return :good if result.stdout.empty?
1212

13-
[:bad, result.stdout]
13+
[:fail, result.stdout]
1414
end
1515
end
1616
end

‎lib/overcommit/hook/pre_commit/haml_lint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def run
1818
modified_lines(file).include?(line.to_i)
1919
end
2020

21-
return :bad, error_lines.join("\n") unless error_lines.empty?
21+
return :fail, error_lines.join("\n") unless error_lines.empty?
2222

2323
[:warn, "Modified files have lints (on lines you didn't modify)\n" <<
2424
warning_lines.join("\n")]

‎lib/overcommit/hook/pre_commit/hard_tabs.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def run
55
# Catches hard tabs
66
result = execute(%w[grep -IHn] + ["\t"] + applicable_files)
77
unless result.stdout.empty?
8-
return :bad, "Hard tabs detected:\n#{result.stdout}"
8+
return :fail, "Hard tabs detected:\n#{result.stdout}"
99
end
1010

1111
:good

‎lib/overcommit/hook/pre_commit/image_optim.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ def run
1212
begin
1313
optimize_images(applicable_files)
1414
rescue ::ImageOptim::BinNotFoundError => e
15-
return :bad, "#{e.message}. The image_optim gem is dependendent on this binary."
15+
return :fail, "#{e.message}. The image_optim gem is dependendent on this binary."
1616
end
1717

1818
if optimized_images.any?
19-
return :bad,
19+
return :fail,
2020
"The following images are optimizable:\n#{optimized_images.join("\n")}" \
2121
"\n\nOptimize them by running:\n" \
2222
" image_optim #{optimized_images.join(' ')}"

‎lib/overcommit/hook/pre_commit/js_hint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def run
1111

1212
return :good if output.empty?
1313

14-
[:bad, output]
14+
[:fail, output]
1515
end
1616
end
1717
end

‎lib/overcommit/hook/pre_commit/jscs.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def run
2323
modified_lines(file).include?(line.to_i)
2424
end
2525

26-
return :bad, error_lines.join("\n") unless error_lines.empty?
26+
return :fail, error_lines.join("\n") unless error_lines.empty?
2727

2828
[:warn, "Modified files have lints (on lines you didn't modify)\n" <<
2929
warning_lines.join("\n")]

‎lib/overcommit/hook/pre_commit/json_syntax.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def run
1616

1717
return :good if output.empty?
1818

19-
[:bad, output]
19+
[:fail, output]
2020
end
2121
end
2222
end

‎lib/overcommit/hook/pre_commit/jsx_hint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def run
1111

1212
return :good if output.empty?
1313

14-
[:bad, output]
14+
[:fail, output]
1515
end
1616
end
1717
end

‎lib/overcommit/hook/pre_commit/merge_conflicts.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def run
55
result = execute(%w[grep -IHn ^<<<<<<<\s] + applicable_files)
66

77
unless result.stdout.empty?
8-
return :bad, "Merge conflict markers detected:\n#{result.stdout}"
8+
return :fail, "Merge conflict markers detected:\n#{result.stdout}"
99
end
1010

1111
:good

‎lib/overcommit/hook/pre_commit/pry_binding.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def run
55
result = execute(%w[grep -IHnE ^\s*binding\.pry] + applicable_files)
66

77
unless result.stdout.empty?
8-
return :bad, "Found a `binding.pry` call left in:\n#{result.stdout}"
8+
return :fail, "Found a `binding.pry` call left in:\n#{result.stdout}"
99
end
1010

1111
:good

‎lib/overcommit/hook/pre_commit/python_flake8.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def run
99
result = execute(%w[flake8] + applicable_files)
1010
return :good if result.success?
1111

12-
[:bad, result.stdout]
12+
[:fail, result.stdout]
1313
end
1414
end
1515
end

‎lib/overcommit/hook/pre_commit/rails_schema_up_to_date.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ module Overcommit::Hook::PreCommit
33
class RailsSchemaUpToDate < Base
44
def run # rubocop:disable CyclomaticComplexity
55
if migration_files.any? && schema_files.none?
6-
return :bad, "It looks like you're adding a migration, but did not update the schema file"
6+
return :fail, "It looks like you're adding a migration, but did not update the schema file"
77
elsif migration_files.none? && schema_files.any?
8-
return :bad, "You're trying to change the schema without adding a migration file"
8+
return :fail, "You're trying to change the schema without adding a migration file"
99
elsif migration_files.any? && schema_files.any?
1010
latest_version = migration_files.map { |file| file[/\d+/] }.sort.last
1111
schema = schema_files.map { |file| File.read(file) }.join
1212
up_to_date = schema.include?(latest_version)
1313

1414
unless up_to_date
15-
return :bad, "The latest migration version you're committing is " \
15+
return :fail, "The latest migration version you're committing is " \
1616
"#{latest_version}, but your schema file " \
1717
"#{schema_files.join(' or ')} is on a different version."
1818
end

‎lib/overcommit/hook/pre_commit/rubocop.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def run
2020
modified_lines(file).include?(line.to_i)
2121
end
2222

23-
return :bad, error_lines.join("\n") unless error_lines.empty?
23+
return :fail, error_lines.join("\n") unless error_lines.empty?
2424

2525
[:warn, "Modified files have lints (on lines you didn't modify)\n" <<
2626
warning_lines.join("\n")]

‎lib/overcommit/hook/pre_commit/scss_lint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def run
1818
modified_lines(file).include?(line.to_i)
1919
end
2020

21-
return :bad, error_lines.join("\n") unless error_lines.empty?
21+
return :fail, error_lines.join("\n") unless error_lines.empty?
2222

2323
[:warn, "Modified files have lints (on lines you didn't modify)\n" <<
2424
warning_lines.join("\n")]

‎lib/overcommit/hook/pre_commit/trailing_whitespace.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class TrailingWhitespace < Base
44
def run
55
result = execute(%w[grep -IHn \s$] + applicable_files)
66
unless result.stdout.empty?
7-
return :bad, "Trailing whitespace detected:\n#{result.stdout}"
7+
return :fail, "Trailing whitespace detected:\n#{result.stdout}"
88
end
99

1010
:good

‎lib/overcommit/hook/pre_commit/travis_lint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def run
99
result = execute(%w[travis-lint] + applicable_files)
1010
return :good if result.success?
1111

12-
[:bad, result.stdout.strip]
12+
[:fail, result.stdout.strip]
1313
end
1414
end
1515
end

‎lib/overcommit/hook/pre_commit/yaml_syntax.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def run
1616

1717
return :good if output.empty?
1818

19-
[:bad, output]
19+
[:fail, output]
2020
end
2121
end
2222
end

‎lib/overcommit/hook_runner.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def run_hooks
4040
@hooks.each do |hook|
4141
hook_status = run_hook(hook)
4242

43-
run_failed = true if hook_status == :bad
43+
run_failed = true if [:bad, :fail].include?(hook_status)
4444

4545
if hook_status == :interrupted
4646
# Stop running any more hooks and assume a bad result
@@ -70,7 +70,7 @@ def run_hook(hook)
7070
InterruptHandler.disable!
7171
status, output = hook.run
7272
rescue => ex
73-
status = :bad
73+
status = :fail
7474
output = "Hook raised unexpected error\n#{ex.message}"
7575
rescue Interrupt
7676
status = :interrupted

‎lib/overcommit/printer.rb

+10-1
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,28 @@ def print_header(hook)
6666
log.partial '.' * (70 - hook.description.length)
6767
end
6868

69-
def print_result(hook, status, output)
69+
def print_result(hook, status, output) # rubocop:disable CyclomaticComplexity, MethodLength
7070
case status
7171
when :good
7272
log.success 'OK' unless hook.quiet?
7373
when :warn
7474
log.warning 'WARNING'
7575
print_report(output, :bold_warning)
7676
when :bad
77+
log.error 'FAILED'
78+
log.bold_error 'Hook returned a status of `:bad`. This is deprecated ' \
79+
'in favor of `:fail` and will be removed in a future ' \
80+
'version of Overcommit'
81+
print_report(output, :bold_error)
82+
when :fail
7783
log.error 'FAILED'
7884
print_report(output, :bold_error)
7985
when :interrupted
8086
log.error 'INTERRUPTED'
8187
print_report(output, :bold_error)
88+
else
89+
log.error '???'
90+
log.bold_error "Hook returned unknown status `#{status.inspect}` -- ignoring." \
8291
end
8392
end
8493

‎spec/overcommit/hook_signer_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def run
5858
module Overcommit::Hook::PreCommit
5959
class SomeHook
6060
def run
61-
:bad # This line changed
61+
:fail # This line changed
6262
end
6363
end
6464
end

‎spec/support/matchers/hook.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def failure_message(actual, error_message)
4040

4141
# Can't use 'fail' as it is a reserved word.
4242
RSpec::Matchers.define :fail_hook do |*args|
43-
check_matcher = HookMatcher.new(:bad, args)
43+
check_matcher = HookMatcher.new(:fail, args)
4444

4545
match do
4646
check_matcher.matches?(actual)

0 commit comments

Comments
 (0)
Please sign in to comment.