Skip to content

Commit a5e0c1a

Browse files
committed
Change YamlSyntax hook to use hook messages
Similar to JsonSyntax, simplify this hook to return hook messages, allowing the framework to determine if a run passed or failed. Change-Id: Ia3c2cdc569752b0ec6edf8f4c81d4a5ef07be9d1 Reviewed-on: http://gerrit.causes.com/47213 Tested-by: jenkins <jenkins@brigade.com> Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
1 parent 533358d commit a5e0c1a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

lib/overcommit/hook/pre_commit/yaml_syntax.rb

+4-6
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@ module Overcommit::Hook::PreCommit
22
# Checks the syntax of any modified YAML files.
33
class YamlSyntax < Base
44
def run
5-
output = []
5+
messages = []
66

77
applicable_files.each do |file|
88
begin
99
YAML.load_file(file)
10-
rescue ArgumentError => e
11-
output << "#{e.message} parsing #{file}"
10+
rescue ArgumentError, Psych::SyntaxError => e
11+
messages << Overcommit::Hook::Message.new(:error, file, nil, e.message)
1212
end
1313
end
1414

15-
return :pass if output.empty?
16-
17-
[:fail, output]
15+
messages
1816
end
1917
end
2018
end

0 commit comments

Comments
 (0)