[PATCH compass-ci] container/defconfig: fix bug

[why] sometimes we may add new yaml file at $HOME/.config/compass-ci/defaults/ if we reference the defconfig.rb before we put anything to the file, error may occur: TypeError: no implicit conversion of false into Hash if the file is not in a standard format of yaml file, error may occur: TypeError: no implicit conversion of String into Hash [how] add update {} for the hash if YAML.load_file() end with errors Signed-off-by: Luan Shengde <shdluan@163.com> --- container/defconfig.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container/defconfig.rb b/container/defconfig.rb index c0768ca..d353bb3 100755 --- a/container/defconfig.rb +++ b/container/defconfig.rb @@ -9,7 +9,7 @@ def cci_defaults hash = {} Dir.glob(['/etc/compass-ci/defaults/*.yaml', "#{ENV['HOME']}/.config/compass-ci/defaults/*.yaml"]).each do |file| - hash.update YAML.load_file(file) + hash.update YAML.load_file(file) || {} end hash end -- 2.23.0
participants (1)
-
Luan Shengde