summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@chef.io>2016-02-26 17:28:45 -0800
committerdanielsdeleo <dan@chef.io>2016-02-26 17:42:30 -0800
commitc170a5addb70ffd014ba9ec6e43d2bd72e56529e (patch)
tree24a377b8ff188191276ce0d1860ed8be52380ac7
parent1691eab8b6b1abcf532858718fabe1bcdd10bd30 (diff)
downloadchef-list-unignored-files.tar.gz
Filter out directory paths from all_files when loadinglist-unignored-files
-rw-r--r--lib/chef/cookbook/cookbook_version_loader.rb2
-rw-r--r--spec/data/cookbooks/openldap/.root_dotfile0
-rw-r--r--spec/unit/cookbook/cookbook_version_loader_spec.rb8
3 files changed, 9 insertions, 1 deletions
diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb
index 5b6cf4b468..6ef9d75030 100644
--- a/lib/chef/cookbook/cookbook_version_loader.rb
+++ b/lib/chef/cookbook/cookbook_version_loader.rb
@@ -230,6 +230,7 @@ class Chef
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 = Chef::Util::PathHelper.cleanpath(file)
name = Chef::Util::PathHelper.relative_path_from(@cookbook_path, file)
cookbook_settings[:all_files][name] = file
@@ -261,7 +262,6 @@ class Chef
glob_pattern = File.join(Chef::Util::PathHelper.escape_glob_dir(cookbook_path, category_dir), "**", glob)
select_files_by_glob(glob_pattern, File::FNM_DOTMATCH).each do |file|
file = Chef::Util::PathHelper.cleanpath(file)
- next if File.directory?(file)
name = Chef::Util::PathHelper.relative_path_from(@cookbook_path, file)
cookbook_settings[category][name] = file
end
diff --git a/spec/data/cookbooks/openldap/.root_dotfile b/spec/data/cookbooks/openldap/.root_dotfile
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/spec/data/cookbooks/openldap/.root_dotfile
diff --git a/spec/unit/cookbook/cookbook_version_loader_spec.rb b/spec/unit/cookbook/cookbook_version_loader_spec.rb
index 0c4814021c..87d0f1e032 100644
--- a/spec/unit/cookbook/cookbook_version_loader_spec.rb
+++ b/spec/unit/cookbook/cookbook_version_loader_spec.rb
@@ -73,8 +73,16 @@ describe Chef::Cookbook::CookbookVersionLoader do
expect(loaded_cookbook.file_filenames).to include(full_path("/files/default/remotedir/.a_dotdir/.a_dotfile_in_a_dotdir"))
end
+ it "loads root files that start with a ." do
+ expect(loaded_cookbook.all_files).to include(full_path(".root_dotfile"))
+ expect(loaded_cookbook.root_filenames).to include(full_path(".root_dotfile"))
+ end
+
it "loads all unignored files, even if they don't match a segment type" do
expect(loaded_cookbook.all_files).to include(full_path("/spec/spec_helper.rb"))
+
+ # Directories need to be filtered out, though:
+ expect(loaded_cookbook.all_files).to_not include(full_path("/spec"))
end
it "should load the metadata for the cookbook" do