From 4356993c6c9231b8a928d1ca55cdd30101610876 Mon Sep 17 00:00:00 2001 From: Alexander Gavrik Date: Thu, 3 Jul 2014 16:58:28 +1100 Subject: [PATCH 1/3] Added skip of git:check git:create_release git:set_current_revision on target and fill current_revision locally just after checkout --- lib/capistrano/rsync.rb | 10 ++++++++++ lib/capistrano/rsync/version.rb | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/capistrano/rsync.rb b/lib/capistrano/rsync.rb index 758d96b..16e1a5f 100644 --- a/lib/capistrano/rsync.rb +++ b/lib/capistrano/rsync.rb @@ -41,13 +41,20 @@ namespace :rsync do task :hook_scm do + Rake::Task["#{scm}:check"].clear Rake::Task.define_task("#{scm}:check") do invoke "rsync:check" end + Rake::Task["#{scm}:create_release"].clear Rake::Task.define_task("#{scm}:create_release") do invoke "rsync:release" end + + Rake::Task["#{scm}:set_current_revision"].clear + Rake::Task.define_task("#{scm}:set_current_revision") do + p "Revision: #{fetch(:current_revision)}" + end end task :check do @@ -71,6 +78,9 @@ checkout = %W[git reset --hard origin/#{fetch(:branch)}] Kernel.system *checkout + + get_current_revision = %x[git rev-parse HEAD] + set(:current_revision, get_current_revision) end end diff --git a/lib/capistrano/rsync/version.rb b/lib/capistrano/rsync/version.rb index f8a14e2..3157bc3 100644 --- a/lib/capistrano/rsync/version.rb +++ b/lib/capistrano/rsync/version.rb @@ -1,5 +1,5 @@ module Capistrano module Rsync - VERSION = "1.0.2" + VERSION = "1.0.2a" end end From d2ddef60aa815641c99c468eb7c848bb4185941c Mon Sep 17 00:00:00 2001 From: Alexander Gavrik Date: Thu, 3 Jul 2014 16:58:28 +1100 Subject: [PATCH 2/3] Added skip of git:check git:create_release git:set_current_revision on target and fill current_revision locally just after checkout --- lib/capistrano/rsync.rb | 15 +++++++++++++++ lib/capistrano/rsync/version.rb | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/capistrano/rsync.rb b/lib/capistrano/rsync.rb index 758d96b..9d2ccbe 100644 --- a/lib/capistrano/rsync.rb +++ b/lib/capistrano/rsync.rb @@ -41,13 +41,20 @@ namespace :rsync do task :hook_scm do + Rake::Task["#{scm}:check"].clear Rake::Task.define_task("#{scm}:check") do invoke "rsync:check" end + Rake::Task["#{scm}:create_release"].clear Rake::Task.define_task("#{scm}:create_release") do invoke "rsync:release" end + + Rake::Task["#{scm}:set_current_revision"].clear + Rake::Task.define_task("#{scm}:set_current_revision") do + # :current_revision was already set during checkout + end end task :check do @@ -74,6 +81,14 @@ end end + after :stage, :set_current_revision + + desc "Set current revision into capistrano variable" + task :set_current_revision do + get_current_revision = %x[git rev-parse HEAD] + set(:current_revision, get_current_revision) + end + desc "Copy the code to the releases directory." task :release => %w[rsync] do # Skip copying if we've already synced straight to the release directory. diff --git a/lib/capistrano/rsync/version.rb b/lib/capistrano/rsync/version.rb index f8a14e2..3157bc3 100644 --- a/lib/capistrano/rsync/version.rb +++ b/lib/capistrano/rsync/version.rb @@ -1,5 +1,5 @@ module Capistrano module Rsync - VERSION = "1.0.2" + VERSION = "1.0.2a" end end From d573325855bf55718cc95168c08a37ca1e37e145 Mon Sep 17 00:00:00 2001 From: Alexander Gavrik Date: Wed, 9 Jul 2014 17:12:50 +1100 Subject: [PATCH 3/3] Fixed type --- lib/capistrano/rsync.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/capistrano/rsync.rb b/lib/capistrano/rsync.rb index 9c6ba11..137c04b 100644 --- a/lib/capistrano/rsync.rb +++ b/lib/capistrano/rsync.rb @@ -81,8 +81,6 @@ end end - after :stage, :set_current_revision - desc "Set current revision into capistrano variable" task :set_current_revision do Dir.chdir fetch(:rsync_stage) do @@ -91,6 +89,8 @@ end end + after :stage, :set_current_revision + desc "Copy the code to the releases directory." task :release => %w[rsync] do # Skip copying if we've already synced straight to the release directory.