From c9cdb6709687ab1d8a904855e3d94f723b8df5fb Mon Sep 17 00:00:00 2001 From: Andrew Curley Date: Wed, 19 Oct 2016 19:33:55 -0400 Subject: [PATCH 1/5] Change set_default to set to fix breaking 1.0.0 change --- lib/mina/rsync.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/mina/rsync.rb b/lib/mina/rsync.rb index ce18d04..277f607 100644 --- a/lib/mina/rsync.rb +++ b/lib/mina/rsync.rb @@ -5,17 +5,17 @@ # private API and internals of Mina::Rsync. If you think something should be # public for extending and hooking, please let me know! -set_default :repository, "." -set_default :branch, "master" -set_default :rsync_options, [] -set_default :rsync_copy, "rsync --archive --acls --xattrs" +set :repository, "." +set :branch, "master" +set :rsync_options, [] +set :rsync_copy, "rsync --archive --acls --xattrs" # Stage is used on your local machine for rsyncing from. -set_default :rsync_stage, "tmp/deploy" +set :rsync_stage, "tmp/deploy" # Cache is used on the server to copy files to from to the release directory. # Saves you rsyncing your whole app folder each time. -set_default :rsync_cache, "shared/deploy" +set :rsync_cache, "shared/deploy" run = lambda do |*cmd| cmd = cmd[0] if cmd[0].is_a?(Array) From fcc2708afd2b2da053fac158f0568235eeb08d14 Mon Sep 17 00:00:00 2001 From: Andrew Curley Date: Wed, 19 Oct 2016 19:38:55 -0400 Subject: [PATCH 2/5] Remove settings as it is a breaking change from mina upgrade --- lib/mina/rsync.rb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/mina/rsync.rb b/lib/mina/rsync.rb index 277f607..56549fa 100644 --- a/lib/mina/rsync.rb +++ b/lib/mina/rsync.rb @@ -24,9 +24,9 @@ end rsync_cache = lambda do - cache = settings.rsync_cache + cache = fetch(:rsync_cache) raise TypeError, "Please set rsync_cache." unless cache - cache = settings.deploy_to + "/" + cache if cache && cache !~ /^\// + cache = fetch(:deploy_to) + "/" + cache if cache && cache !~ /^\// cache end @@ -35,11 +35,11 @@ print_status "Rsyncing to #{rsync_cache.call}..." rsync = %w[rsync] - rsync.concat settings.rsync_options - rsync << settings.rsync_stage + "/" + rsync.concat fetch(:rsync_options) + rsync << fetch(:rsync_stage) + "/" - user = settings.user + "@" if settings.user - host = settings.domain + user = fetch(:user) + "@" if fetch(:user) + host = fetch(:domain) rsync << "#{user}#{host}:#{rsync_cache.call}" run.call rsync @@ -47,12 +47,12 @@ namespace :rsync do task :create_stage do - next if File.directory?(settings.rsync_stage) + next if File.directory?(fetch(:rsync_stage)) print_status "Cloning repository for the first time..." clone = %w[git clone] - clone << settings.repository - clone << settings.rsync_stage + clone << fetch(:repository) + clone << fetch(:rsync_stage) run.call clone end @@ -60,19 +60,19 @@ task :stage => %w[create_stage] do print_status "Staging..." - stage = settings.rsync_stage + stage = fetch(:rsync_stage) git = %W[git --git-dir #{stage}/.git --work-tree #{stage}] run.call git + %w[fetch --quiet --all --prune] # Prefix the Git "HEAD is now at" message, but only if verbose is unset, # because then the #print_command called by #run prints its own prefix. print "Git checkout: " unless simulate_mode? || verbose_mode? - run.call git + %W[reset --hard origin/#{settings.branch}] + run.call git + %W[reset --hard origin/#{fetch(:branch)}] end task :build do queue %(echo "-> Copying from cache directory to build path") - queue! %(#{settings.rsync_copy} "#{rsync_cache.call}/" ".") + queue! %(#{fetch(:rsync_copy)} "#{rsync_cache.call}/" ".") end desc "Stage, rsync and copy to the build path." From 70c8a6fe6c4619663a18b86fe21a774310acea8f Mon Sep 17 00:00:00 2001 From: Andrew Curley Date: Wed, 19 Oct 2016 19:42:19 -0400 Subject: [PATCH 3/5] Update simulate_mode? and verbose_mode? to new non-breaking changes --- lib/mina/rsync.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/mina/rsync.rb b/lib/mina/rsync.rb index 56549fa..2486e23 100644 --- a/lib/mina/rsync.rb +++ b/lib/mina/rsync.rb @@ -19,8 +19,8 @@ run = lambda do |*cmd| cmd = cmd[0] if cmd[0].is_a?(Array) - print_command cmd.join(" ") if simulate_mode? || verbose_mode? - Kernel.system *cmd unless simulate_mode? + print_command cmd.join(" ") if fetch(:simulate) || fetch(:verbose) + Kernel.system *cmd unless fetch(:simulate) end rsync_cache = lambda do @@ -66,7 +66,7 @@ # Prefix the Git "HEAD is now at" message, but only if verbose is unset, # because then the #print_command called by #run prints its own prefix. - print "Git checkout: " unless simulate_mode? || verbose_mode? + print "Git checkout: " unless fetch(:simulate) || fetch(:verbose) run.call git + %W[reset --hard origin/#{fetch(:branch)}] end From d75150df5ce2fa2e8cb8b825f8bf0f04199402c7 Mon Sep 17 00:00:00 2001 From: Andrew Curley Date: Wed, 19 Oct 2016 19:44:04 -0400 Subject: [PATCH 4/5] Update queue -> command --- lib/mina/rsync.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mina/rsync.rb b/lib/mina/rsync.rb index 2486e23..aeb05cc 100644 --- a/lib/mina/rsync.rb +++ b/lib/mina/rsync.rb @@ -71,8 +71,8 @@ end task :build do - queue %(echo "-> Copying from cache directory to build path") - queue! %(#{fetch(:rsync_copy)} "#{rsync_cache.call}/" ".") + command %(echo "-> Copying from cache directory to build path") + command! %(#{fetch(:rsync_copy)} "#{rsync_cache.call}/" ".") end desc "Stage, rsync and copy to the build path." From 3f92fc1a307d5e10cc8586d4b14196b7889baff1 Mon Sep 17 00:00:00 2001 From: Andrew Curley Date: Wed, 19 Oct 2016 19:45:03 -0400 Subject: [PATCH 5/5] Fix typo --- lib/mina/rsync.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mina/rsync.rb b/lib/mina/rsync.rb index aeb05cc..3c929ec 100644 --- a/lib/mina/rsync.rb +++ b/lib/mina/rsync.rb @@ -72,7 +72,7 @@ task :build do command %(echo "-> Copying from cache directory to build path") - command! %(#{fetch(:rsync_copy)} "#{rsync_cache.call}/" ".") + command %(#{fetch(:rsync_copy)} "#{rsync_cache.call}/" ".") end desc "Stage, rsync and copy to the build path."