diff options
author | John Keiser <john@johnkeiser.com> | 2016-08-17 08:48:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-17 08:48:07 -0700 |
commit | 4da546bd2431a6ecf86d9f709714c3de8b13d8fb (patch) | |
tree | f6eafbf03db3e9b61acc551f9fcc90664955adb4 /lib/chef/cookbook/cookbook_version_loader.rb | |
parent | 5de6251cf05ce43945c23dfdb6fe956bebd9bab7 (diff) | |
parent | 438cd46c773fb752556d1ed61e49ad0a359fc059 (diff) | |
download | chef-4da546bd2431a6ecf86d9f709714c3de8b13d8fb.tar.gz |
Merge pull request #5215 from chef/jk/windows-ruby-2.3
Don't use relative_path_from on glob results
Diffstat (limited to 'lib/chef/cookbook/cookbook_version_loader.rb')
-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 cf72426740..56fe3838d9 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 |