-
Notifications
You must be signed in to change notification settings - Fork 84
Ignore .DS_Store files during upload #284
Comments
I will send an Oregon gift basket to anyone that fixes this bug. One of the more annoying bugs out there for my workflow |
I am really not sure, if this bug report belongs really to ridley - i posted the same comment in berkshelf/berkshelf#706 because i assume that berkshelf is collecting the data for uploading them to the chef-server. Unfortunately this problem was not solved for me (berks version 3.2.3) and it also had nothing to do with any My error was caused by having files placed directly in the files/template-folder. I was able to solve the problem by moving the designated files into an additional subdirectory: Wrong
lead to: Right
|
I guess that the problem may be about that ridley and knife are ignoring files in a little bit different way: ridley uses the buff-ignore library to determine if a file should be ignored, and knife uses Chef::Cookbook::Chefignore class. Ridley chef/cookbook.rb and chef/chefignore.rb # chef/cookbook.rb
308: def ignored?(file)
309: !!chefignore && chefignore.ignored?(file)
310: end
# chef/chefignore.rb
004: class Chefignore < Buff::Ignore::IgnoreFile Knife chef/cookbook/cookbook_version_loader.rb 243: def remove_ignored_files
244: cookbook_settings.each_value do |file_list|
245: file_list.reject! do |relative_path, full_path|
246: chefignore.ignored?(relative_path)
247: end
248: end
249: end Both buff-ignore and Chef::Cookbook::Chefignore are using File.fnmatch? method to check file name against chefignore pattern: Buff-Ignore ignore/ignore_file.rb 073: def ignored?(filename)
074: base = File.expand_path(options[:base] || File.dirname(filepath))
075: basename = filename.sub(base + File::SEPARATOR, '')
076:
077: ignores.any? { |ignore| File.fnmatch?(ignore, basename) }
078: end Knife chef/cookbook/chefignore.rb 042: def ignored?(file_name)
043: @ignores.any? {|glob| File.fnmatch?(glob, file_name)}
044: end And both are trying to use filename relative to the cookbook folder. But since buff-ignore created without the options hash: 090: @chefignore = Ridley::Chef::Chefignore.new(@path) rescue nil It will use File.dirname(filepath) which will be evaluated not to the cookbooks folder but to the folder one level up. Thus, for example, if one has chefignore.rb with the following content
then ridley will use cookboook/README.md as filename to define if the file should be ignored, and knife will use README.md. And, that's why in this case the readme will be ignored by knife but not by ridley and berkshelf. Probably this can solve the bug: |
@sethvargo - When you get time, I think this just needs a new release of the buff-ignore gem so that Berks will receive this fix? (you merged Grelkins PR back in March) (CAVEAT: I may be confused about how github/gems etc work) |
Closing this since https://github.com/sethvargo/buff-ignore/pull/3 releases buff-ignore. Thanks for pointing that out @jhsubscribe |
Migrated from berkshelf/berkshelf#706, Ridley should ignore .DS_Store files from the cookbook. It causes strange problems during upload as noted in that issue.
The text was updated successfully, but these errors were encountered: