Skip to content

Commit

Permalink
Deduplicate push checking
Browse files Browse the repository at this point in the history
  • Loading branch information
IntractableQuery committed Oct 29, 2014
1 parent ae25656 commit 25f82f6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/capistrano-db-tasks/dbtasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@
set :skip_data_sync_confirm, (ENV['SKIP_DATA_SYNC_CONFIRM'].to_s.downcase == 'true')
set :disallow_pushing, false unless fetch(:disallow_pushing)

namespace :capistrano_db_tasks do
task :check_can_push do
raise "pushing is disabled, set disallow_pushing to false to carry out this operation" if fetch(:disallow_pushing)
end
end

namespace :db do
namespace :remote do
desc 'Synchronize your remote database using local database data'
task :sync do
task :sync => 'capistrano_db_tasks:check_can_push' do
on roles(:db) do
raise "pushing is disabled, set disallow_pushing to false to carry out this operation" if fetch(:disallow_pushing)
if fetch(:skip_data_sync_confirm) || Util.prompt('Are you sure you want to REPLACE THE REMOTE DATABASE with local database')
Database.local_to_remote(self)
end
Expand Down Expand Up @@ -45,10 +50,9 @@
namespace :assets do
namespace :remote do
desc 'Synchronize your remote assets using local assets'
task :sync do
task :sync => 'capistrano_db_tasks:check_can_push' do
on roles(:app) do
puts "Assets directories: #{fetch(:assets_dir)}"
raise "pushing is disabled, set disallow_pushing to false to carry out this operation" if fetch(:disallow_pushing)
if fetch(:skip_data_sync_confirm) || Util.prompt("Are you sure you want to erase your server assets with local assets")
Asset.local_to_remote(self)
end
Expand Down Expand Up @@ -78,8 +82,7 @@
namespace :app do
namespace :remote do
desc 'Synchronize your remote assets AND database using local assets and database'
task :sync do
raise "pushing is disabled, set disallow_pushing to false to carry out this operation" if fetch(:disallow_pushing)
task :sync => 'capistrano_db_tasks:check_can_push' do
if fetch(:skip_data_sync_confirm) || Util.prompt("Are you sure you want to REPLACE THE REMOTE DATABASE AND your remote assets with local database and assets(#{fetch(:assets_dir)})")
on roles(:db) do
Database.local_to_remote(self)
Expand Down

0 comments on commit 25f82f6

Please sign in to comment.