Skip to content

Commit

Permalink
anchor the directory regex in .afignore
Browse files Browse the repository at this point in the history
  • Loading branch information
lhitchon committed Nov 6, 2012
1 parent 36e0864 commit cdee848
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/cli/file_helper.rb
Expand Up @@ -58,7 +58,7 @@ def match(pattern,filename)
if pattern =~ /\/$/
# pattern ending in a slash should ignore directory and all its children
dirname = pattern.sub(/\/$/,'')
return filename == dirname || filename =~ /#{dirname}\/.*$/
return filename == dirname || filename =~ /^#{dirname}\/.*$/
end

if pattern =~ /^\//
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/version.rb
Expand Up @@ -2,6 +2,6 @@ module VMC
module Cli
# This version number is used as the RubyGem release version.
# The internal VMC version number is VMC::VERSION.
VERSION = '0.3.18.10'
VERSION = '0.3.18.11'
end
end
24 changes: 24 additions & 0 deletions spec/unit/file_helper_spec.rb
Expand Up @@ -86,6 +86,30 @@
files = %W(/project/index.html /project/about.html)
afi.included_files(files).should == %W(/project/index.html)
end

it 'should anchor directory patterns' do
afi = VMC::Cli::FileHelper::AppFogIgnore.new(%W(data/))
files = %W(data/one.html data/two.html another/data/one.html)
afi.included_files(files).should == %W(another/data/one.html)
end

it 'should anchor directory patterns with regex' do
afi = VMC::Cli::FileHelper::AppFogIgnore.new(%W(da.*/))
files = %W(data/one.html data/two.html another/data/one.html)
afi.included_files(files).should == %W(another/data/one.html)
end

it 'should anchor directory patterns with regex' do
afi = VMC::Cli::FileHelper::AppFogIgnore.new(%W(.*da.*/))
files = %W(data/one.html data/two.html another/data/one.html index.html)
afi.included_files(files).should == %W(index.html)
end

it 'should anchor file patterns' do
afi = VMC::Cli::FileHelper::AppFogIgnore.new(%W(one.html))
files = %W(one.html sub/one.html)
afi.included_files(files).should == %W(sub/one.html)
end

end

Expand Down

0 comments on commit cdee848

Please sign in to comment.