1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

fix/role_filter greedy matching (#1771)

* fix/role_filter greedy matching

* fixed CHANGELOG.md
This commit is contained in:
Carsten Seeger 2016-09-07 16:39:28 +02:00 committed by Matt Brictson
parent e27b0322f2
commit d732fa432f
3 changed files with 19 additions and 3 deletions

View file

@ -8,7 +8,7 @@ https://github.com/capistrano/capistrano/compare/v3.6.1...HEAD
* Your contribution here!
* `remote_file` feature has been removed and is no longer available to use @SaiVardhan
* fix bug with greedy matching in host_filter [#1766](https://github.com/capistrano/capistrano/issues/1766) (@cseeger-epages)
* Fix bug where host_filter and role_filter were overly greedy [#1766](https://github.com/capistrano/capistrano/issues/1766) (@cseeger-epages)
## `3.6.1` (2016-08-23)

View file

@ -20,7 +20,7 @@ module Capistrano
when Regexp then v
else
vs = v.to_s
vs =~ %r{^/(.+)/$} ? Regexp.new($1) : /^#{vs}$/
vs =~ %r{^/(.+)/$} ? Regexp.new($1) : /^#{Regexp.quote(vs)}$/
end
end
Regexp.union values

View file

@ -11,7 +11,8 @@ module Capistrano
Server.new("server2").add_role(:web),
Server.new("server3").add_role(:redis),
Server.new("server4").add_role(:db),
Server.new("server5").add_role(:stageweb)
Server.new("server5").add_role(:stageweb),
Server.new("server6").add_role(:"db.new")
]
end
@ -58,6 +59,21 @@ module Capistrano
let(:values) { "db,/red/" }
it_behaves_like "it filters roles correctly", 3, %w{server1 server3 server4}
end
context "with a dot wildcard" do
let(:values) { "db.*" }
it_behaves_like "it filters roles correctly", 0, %w{}
end
context "with a dot" do
let(:values) { "db.new" }
it_behaves_like "it filters roles correctly", 1, %w{server6}
end
context "with a dot wildcard regex" do
let(:values) { "/db.*/" }
it_behaves_like "it filters roles correctly", 3, %w{server1 server4 server6}
end
end
end
end