diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-05-03 14:26:01 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2019-05-29 14:19:03 -0700 |
commit | d118f8246060bed4b1a596437ee5ef7de584e293 (patch) | |
tree | f8d0516dcfb8fe4d60719a083eeaa89f009a907d | |
parent | 6a613c538b386f72f66548523a8f9400207d2a95 (diff) | |
download | chef-backport_11.tar.gz |
fix knife diff exceptionsbackport_11
closes #4189
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | lib/chef/chef_fs/command_line.rb | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/chef/chef_fs/command_line.rb b/lib/chef/chef_fs/command_line.rb index 5f449bad04..a61c68ceda 100644 --- a/lib/chef/chef_fs/command_line.rb +++ b/lib/chef/chef_fs/command_line.rb @@ -1,6 +1,6 @@ # # Author:: John Keiser (<jkeiser@chef.io>) -# Copyright:: Copyright 2012-2016, Chef Software Inc. +# Copyright:: Copyright 2012-2019, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -271,19 +271,18 @@ class Chef new_tempfile.write(new_value) new_tempfile.close - begin - old_tempfile = Tempfile.new("old") - old_tempfile.write(old_value) - old_tempfile.close + old_tempfile = Tempfile.new("old") + old_tempfile.write(old_value) + old_tempfile.close - result = Chef::Util::Diff.new.udiff(old_tempfile.path, new_tempfile.path) - result = result.gsub(/^--- #{old_tempfile.path}/, "--- #{old_path}") - result = result.gsub(/^\+\+\+ #{new_tempfile.path}/, "+++ #{new_path}") - result - ensure - old_tempfile.close! - end + result = Chef::Util::Diff.new.udiff(old_tempfile.path, new_tempfile.path) + result = result.gsub(/^--- #{old_tempfile.path}/, "--- #{old_path}") + result = result.gsub(/^\+\+\+ #{new_tempfile.path}/, "+++ #{new_path}") + result + rescue => e + "!!! Unable to diff #{old_path} and #{new_path} due to #{e}" ensure + old_tempfile.close! new_tempfile.close! end end |