diff options
author | John Keiser <john@johnkeiser.com> | 2016-08-16 16:37:50 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2016-08-16 17:22:02 -0700 |
commit | 438cd46c773fb752556d1ed61e49ad0a359fc059 (patch) | |
tree | 7b6e44632f379d0e08a9f8be0438b71b0c9005c6 /lib/chef/cookbook | |
parent | 51581a0d11ddfac8db97712c6c3c680910db706c (diff) | |
download | chef-438cd46c773fb752556d1ed61e49ad0a359fc059.tar.gz |
Don't use relative_path_from on glob resultsjk/windows-ruby-2.3
Windows Ruby 2.3 translates pathnames like ADMINI~1 to Administrator, making the comparison fail.
Diffstat (limited to 'lib/chef/cookbook')
-rw-r--r-- | lib/chef/cookbook/cookbook_version_loader.rb | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb index d9b027f322..5683ca7de7 100644 --- a/lib/chef/cookbook/cookbook_version_loader.rb +++ b/lib/chef/cookbook/cookbook_version_loader.rb @@ -3,6 +3,7 @@ require "chef/cookbook_version" require "chef/cookbook/chefignore" require "chef/cookbook/metadata" require "chef/util/path_helper" +require "find" class Chef class Cookbook @@ -223,27 +224,19 @@ class Chef # however if the file is named ".uploaded-cookbook-version.json" it is # assumed to be managed by chef-zero and not part of the cookbook. def load_all_files - Dir.glob(File.join(Chef::Util::PathHelper.escape_glob_dir(cookbook_path), "*"), File::FNM_DOTMATCH).each do |fs_entry| - if File.directory?(fs_entry) - dir_relpath = Chef::Util::PathHelper.relative_path_from(@cookbook_path, fs_entry) - - next if dir_relpath.to_s.start_with?(".") - - Dir.glob(File.join(fs_entry, "**/*"), File::FNM_DOTMATCH).each do |file| - next if File.directory?(file) - file = Pathname.new(file).cleanpath.to_s - name = Chef::Util::PathHelper.relative_path_from(@cookbook_path, file) - cookbook_settings[:all_files][name] = file - end - elsif File.file?(fs_entry) - file = Pathname.new(fs_entry).cleanpath.to_s - - next if File.basename(file) == UPLOADED_COOKBOOK_VERSION_FILE - - name = Chef::Util::PathHelper.relative_path_from(@cookbook_path, file) - cookbook_settings[:all_files][name] = file - else # pipes, devices, other weirdness - next + return unless File.exist?(cookbook_path) + # The trailing / tells find to traverse the top level symlink + Find.find("#{cookbook_path}/") do |path| + relative_path = Chef::Util::PathHelper.relative_path_from(@cookbook_path, path) + path = Pathname.new(path).cleanpath.to_s + + # Skip top-level directories starting with "." + if File.directory?(path) && relative_path.to_s.start_with?(".") && relative_path.to_s != "." + Find.prune + + # Add files to the list of files + elsif File.file?(path) && File.basename(relative_path) != UPLOADED_COOKBOOK_VERSION_FILE + cookbook_settings[:all_files][relative_path] = path end end end |