Skip to content

Commit

Permalink
Updated git recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandoaleman committed May 21, 2013
1 parent 1db2e2e commit e08dcd8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/capistrano/recipes/git.rb
Expand Up @@ -26,7 +26,11 @@ def self.load_into(configuration)
end

after 'deploy:setup' do
run "git clone --no-checkout #{repository} #{current_path}"
unless remote_directory_exists?(current_path)
run "git clone --no-checkout #{repository} #{current_path}"
else
say "#{current_path} already exists, skipping..."
end
end

namespace :deploy do
Expand Down
8 changes: 8 additions & 0 deletions lib/capistrano_recipes.rb
Expand Up @@ -89,6 +89,14 @@ def say(message)
m = "\n#{message}"
Capistrano::CLI.ui.say(m)
end

def remote_directory_exists?(path)
invoke_command("if [[ -d #{path} ]]; then echo -n 'true'; fi") do |channel, stream, data|
results = (data == 'true')
end

results
end

namespace :deploy do
desc 'Deploy application'
Expand Down

0 comments on commit e08dcd8

Please sign in to comment.