You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by as...@apache.org on 2009/03/06 02:38:03 UTC

svn commit: r750743 - in /buildr/trunk: CHANGELOG lib/buildr/core/filter.rb lib/buildr/packaging/archive.rb lib/buildr/packaging/ziptask.rb spec/packaging/archive_spec.rb

Author: assaf
Date: Fri Mar  6 01:38:03 2009
New Revision: 750743

URL: http://svn.apache.org/viewvc?rev=750743&view=rev
Log:
Fixed:  BUILDR-263: package(:war).merge not working correctly with exclude()

Modified:
    buildr/trunk/CHANGELOG
    buildr/trunk/lib/buildr/core/filter.rb
    buildr/trunk/lib/buildr/packaging/archive.rb
    buildr/trunk/lib/buildr/packaging/ziptask.rb
    buildr/trunk/spec/packaging/archive_spec.rb

Modified: buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=750743&r1=750742&r2=750743&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Fri Mar  6 01:38:03 2009
@@ -39,6 +39,7 @@
 * Fixed:  BUILDR-214 Buildr is stuck uploading to sftp repository (Heikki Hulkko).
 * Fixed:  BUILDR-216 Profiles documentation is wrong (Shane Witbeck).
 * Fixed:  BUILDR-261: ScalaSpecs should be run with Scala dependencies
+* Fixed:  BUILDR-263: package(:war).merge not working correctly with exclude()
 
 1.3.3 (2008-10-08)
 * Added:  JtestR support. Implemented pending jtestr specs.

Modified: buildr/trunk/lib/buildr/core/filter.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/filter.rb?rev=750743&r1=750742&r2=750743&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/filter.rb (original)
+++ buildr/trunk/lib/buildr/core/filter.rb Fri Mar  6 01:38:03 2009
@@ -165,8 +165,8 @@
       copy_map = sources.flatten.map(&:to_s).inject({}) do |map, source|
         files = Util.recursive_with_dot_files(source).
           map { |file| Util.relative_path(file, source) }.
-          select { |file| @include.empty? || @include.any? { |pattern| File.fnmatch(pattern, file, File::FNM_PATHNAME) } }.
-          reject { |file| @exclude.any? { |pattern| File.fnmatch(pattern, file, File::FNM_PATHNAME) } }
+          select { |file| @include.empty? || @include.any? { |pattern| File.fnmatch(pattern, file) } }.
+          reject { |file| @exclude.any? { |pattern| File.fnmatch(pattern, file) } }
         files.each do |file|
           src, dest = File.expand_path(file, source), File.expand_path(file, target.to_s)
           map[file] = src if !File.exist?(dest) || File.stat(src).mtime >= File.stat(dest).mtime

Modified: buildr/trunk/lib/buildr/packaging/archive.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging/archive.rb?rev=750743&r1=750742&r2=750743&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/packaging/archive.rb (original)
+++ buildr/trunk/lib/buildr/packaging/archive.rb Fri Mar  6 01:38:03 2009
@@ -153,7 +153,7 @@
       # Returns true if this ZIP file path contains all the specified files. You can use relative
       # file names and glob patterns (using *, **, etc).
       def contain?(*files)
-        files.all? { |file| entries.detect { |entry| File.fnmatch(file, entry.to_s, File::FNM_PATHNAME) } }
+        files.all? { |file| entries.detect { |entry| File.fnmatch(file, entry.to_s) } }
       end
 
       # :call-seq:
@@ -200,7 +200,7 @@
       end
 
       def excluded?(file)
-        @excludes.any? { |exclude| File.fnmatch(exclude, file, File::FNM_PATHNAME) }
+        @excludes.any? { |exclude| File.fnmatch(exclude, file) }
       end
 
       def entries #:nodoc:
@@ -253,11 +253,11 @@
       end
 
       def expand(file_map, path)
-        @includes = ['**/*'] if @includes.empty?
+        @includes = ['*'] if @includes.empty?
         Zip::ZipFile.open(@zip_file) do |source|
           source.entries.reject { |entry| entry.directory? }.each do |entry|
-            if @includes.any? { |pattern| File.fnmatch(pattern, entry.name, File::FNM_PATHNAME) } &&
-               !@excludes.any? { |pattern| File.fnmatch(pattern, entry.name, File::FNM_PATHNAME) }
+            if @includes.any? { |pattern| File.fnmatch(pattern, entry.name) } &&
+               !@excludes.any? { |pattern| File.fnmatch(pattern, entry.name) }
               dest = path =~ /^\/?$/ ? entry.name : Util.relative_path(path + "/" + entry.name)
               trace "Adding #{dest}"
               file_map[dest] = lambda { |output| output.write source.read(entry) }

Modified: buildr/trunk/lib/buildr/packaging/ziptask.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging/ziptask.rb?rev=750743&r1=750742&r2=750743&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/packaging/ziptask.rb (original)
+++ buildr/trunk/lib/buildr/packaging/ziptask.rb Fri Mar  6 01:38:03 2009
@@ -256,13 +256,13 @@
       end
 
       def map(entries)
-        includes = @include || ['**/*']
+        includes = @include || ['*']
         excludes = @exclude || []
         entries.inject({}) do |map, entry|
           if entry.name =~ /^#{@path}/
             short = entry.name.sub(@path, '')
-            if includes.any? { |pat| File.fnmatch(pat, short, File::FNM_PATHNAME) } &&
-               !excludes.any? { |pat| File.fnmatch(pat, short, File::FNM_PATHNAME) }
+            if includes.any? { |pat| File.fnmatch(pat, short) } &&
+               !excludes.any? { |pat| File.fnmatch(pat, short) }
               map[short] = entry
             end
           end

Modified: buildr/trunk/spec/packaging/archive_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/packaging/archive_spec.rb?rev=750743&r1=750742&r2=750743&view=diff
==============================================================================
--- buildr/trunk/spec/packaging/archive_spec.rb (original)
+++ buildr/trunk/spec/packaging/archive_spec.rb Fri Mar  6 01:38:03 2009
@@ -237,6 +237,16 @@
     end
   end
 
+  it 'should expand another archive file with nested exclude pattern' do
+    @files = %w{Test1.txt Text2.html}.map { |file| File.join(@dir, "foo", file) }.
+      each { |file| write file, content_for(file) }
+    zip(@archive + '.src').include(@dir).tap do |task|
+      archive(@archive).merge(task).exclude('test/*')
+      archive(@archive).invoke
+      inspect_archive.should be_empty
+    end
+  end
+
   it 'should expand another archive file into path' do
     create_for_merge do |src|
       archive(@archive).path('test').merge(src)