Only exclude top-level metadata.rb file while vendoring

This should fix issue #1344.
Ah, boo. Well thanks for this fix! A test would be greatly appreciated to avoid regressions ;)

Jamie Winsor
@resetexistence

> On Dec 6, 2014, at 3:42 PM, Jim Pruetting <notifications@github.com> wrote:
> 
> In lib/berkshelf/berksfile.rb:
> 
> > @@ -618,7 +621,7 @@ def vendor(destination)
> >          #
> >          #   * https://tickets.opscode.com/browse/CHEF-4811
> >          #   * https://tickets.opscode.com/browse/CHEF-4810
> > -        FileSyncer.sync(scratch, destination, exclude: ['**/metadata.rb'] + EXCLUDED_VCS_FILES_WHEN_VENDORING)
> I tried that, but it wouldn't work. The source_files variable in FileSyncer.sync contains relative paths that look like this:
> 
> apt/metadata.rb
> artifact/metadata.rb
> build-essential/metadata.rb
> chef_handler/metadata.rb
> windows/metadata.rb
> my_cookbook/metadata.rb
> my_cookbook/recipes/metadata.rb
> Here are the results of testing different matches against top-level and nested file locations:
> 
> # top-level metadata.rb
> File.fnmatch?("metadata.rb", "my_cookbook/metadata.rb", File::FNM_DOTMATCH) # false
> File.fnmatch?("/metadata.rb", "my_cookbook/metadata.rb", File::FNM_DOTMATCH) # false
> File.fnmatch?("*/metadata.rb", "my_cookbook/metadata.rb", File::FNM_DOTMATCH) # true
> File.fnmatch?("**/metadata.rb", "my_cookbook/metadata.rb", File::FNM_DOTMATCH) # true
> File.fnmatch?("*/**/metadata.rb", "my_cookbook/metadata.rb", File::FNM_DOTMATCH) # false
> 
> # nested metadata.rb
> File.fnmatch?("metadata.rb", "my_cookbook/recipes/metadata.rb", File::FNM_DOTMATCH) # false
> File.fnmatch?("/metadata.rb", "my_cookbook/recipes/metadata.rb", File::FNM_DOTMATCH) # false
> File.fnmatch?("*/metadata.rb", "my_cookbook/recipes/metadata.rb", File::FNM_DOTMATCH) # true
> File.fnmatch?("**/metadata.rb", "my_cookbook/recipes/metadata.rb", File::FNM_DOTMATCH) # true
> File.fnmatch?("*/**/metadata.rb", "my_cookbook/recipes/metadata.rb", File::FNM_DOTMATCH) # true
> —
> Reply to this email directly or view it on GitHub.
>