Skip to content

Commit 33d4ae7

Browse files
authored
Fix YamlSyntax to specify aliases option (#772)
1 parent c142cd2 commit 33d4ae7

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/overcommit/hook/pre_commit/yaml_syntax.rb

+7-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ def run
88

99
applicable_files.each do |file|
1010
begin
11-
YAML.load_file(file)
12-
rescue ArgumentError, Psych::SyntaxError => e
13-
messages << Overcommit::Hook::Message.new(:error, file, nil, e.message)
11+
YAML.load_file(file, aliases: true)
12+
rescue ArgumentError
13+
begin
14+
YAML.load_file(file)
15+
rescue ArgumentError, Psych::SyntaxError => e
16+
messages << Overcommit::Hook::Message.new(:error, file, nil, e.message)
17+
end
1418
end
1519
end
1620

spec/overcommit/hook/pre_commit/yaml_syntax_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
context 'when YAML file has errors' do
2424
before do
25+
YAML.stub(:load_file).with(staged_file, { aliases: true }).and_raise(ArgumentError)
2526
YAML.stub(:load_file).with(staged_file).and_raise(ArgumentError)
2627
end
2728

0 commit comments

Comments
 (0)