Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Oct 19, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/recap/support/capistrano_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ def changed_files
end

def trigger_update?(path)
force_full_deploy || changed_files.detect {|p| p[0, path.length] == path}
force_full_deploy || changed_files.detect {|p|
if path.is_a?(Regexp)
p =~ path
else
p[0, path.length] == path
end
}
end

def claim_lock(message)
Expand Down
16 changes: 16 additions & 0 deletions spec/models/capistrano_extensions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@
it 'returns true for a directory path which contains a changed file' do
config.trigger_update?('directory/containing/changed/').should be_true
end

it 'returns true for a regex that matches a changed file' do
config.trigger_update?(/^path\/to\/changed\/file/).should be_true
end

it 'returns false for a regex that does not match a changed file' do
config.trigger_update?(/^no\/changes\/here/).should be_false
end

it 'returns false for a regex matching a directory with no changes' do
config.trigger_update?(/^no\/changes\//).should be_false
end

it 'returns true for a regex matching a directory with changes' do
config.trigger_update?(/^path\/to\//).should be_true
end
end
end
end