summaryrefslogtreecommitdiff
path: root/chef
diff options
context:
space:
mode:
authorTeemu Matilainen <teemu.matilainen@reaktor.fi>2012-10-30 13:34:42 -0300
committerBryan McLellan <btm@opscode.com>2012-11-20 13:02:25 -0800
commit647f7c9f835f890ba210a85de1ca776da4a5cfba (patch)
tree1ed370520264f32cab09964e2a5f1eb923f7fd16 /chef
parent46f58b13432085f28ca2aaadaed5ab54b5d536ae (diff)
downloadchef-647f7c9f835f890ba210a85de1ca776da4a5cfba.tar.gz
[CHEF-3572] Fix chefignore whitespace matching
`COMMENTS_AND_WHITESPACE` matched lines starting with word characters (\w) when it should have matched whitespaces (\s). Thus comment lines starting with spaces were not skipped but filenames with only word characters were.
Diffstat (limited to 'chef')
-rw-r--r--chef/lib/chef/cookbook/chefignore.rb2
-rw-r--r--chef/spec/data/cookbooks/chefignore2
-rw-r--r--chef/spec/unit/cookbook/chefignore_spec.rb3
3 files changed, 5 insertions, 2 deletions
diff --git a/chef/lib/chef/cookbook/chefignore.rb b/chef/lib/chef/cookbook/chefignore.rb
index e9d54639e4..af145f3a3c 100644
--- a/chef/lib/chef/cookbook/chefignore.rb
+++ b/chef/lib/chef/cookbook/chefignore.rb
@@ -20,7 +20,7 @@ class Chef
class Cookbook
class Chefignore
- COMMENTS_AND_WHITESPACE = /^\w*(?:#.*)?$/
+ COMMENTS_AND_WHITESPACE = /^\s*(?:#.*)?$/
attr_reader :ignores
diff --git a/chef/spec/data/cookbooks/chefignore b/chef/spec/data/cookbooks/chefignore
index cfd4e65832..84b4f1e99f 100644
--- a/chef/spec/data/cookbooks/chefignore
+++ b/chef/spec/data/cookbooks/chefignore
@@ -4,3 +4,5 @@
#
recipes/ignoreme.rb
+ # comments can be indented
+ignored
diff --git a/chef/spec/unit/cookbook/chefignore_spec.rb b/chef/spec/unit/cookbook/chefignore_spec.rb
index 30b97e865d..aacb60c012 100644
--- a/chef/spec/unit/cookbook/chefignore_spec.rb
+++ b/chef/spec/unit/cookbook/chefignore_spec.rb
@@ -23,7 +23,7 @@ describe Chef::Cookbook::Chefignore do
end
it "loads the globs in the chefignore file" do
- @chefignore.ignores.should =~ %w[recipes/ignoreme.rb]
+ @chefignore.ignores.should =~ %w[recipes/ignoreme.rb ignored]
end
it "removes items from an array that match the ignores" do
@@ -32,6 +32,7 @@ describe Chef::Cookbook::Chefignore do
end
it "determines if a file is ignored" do
+ @chefignore.ignored?('ignored').should be_true
@chefignore.ignored?('recipes/ignoreme.rb').should be_true
@chefignore.ignored?('recipes/dontignoreme.rb').should be_false
end