From f27a36fbf2824200692f66b9663a5fa450c9d567 Mon Sep 17 00:00:00 2001 From: Lennart Weijl Date: Wed, 15 Jul 2015 16:52:35 +0200 Subject: [PATCH 1/3] Adds support for checking out revisions on top of tags and branches --- README.md | 3 ++- lib/capistrano/rsync.rb | 26 +++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5db8fff..cda35f1 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,8 @@ rsync_cache | `shared/deploy` | Path where to cache your repository on the ser rsync_options | `[]` | Array of options to pass to `rsync`. rsync_sparse_checkout | `[]` | Array of directories to checkout (checks out all if empty) rsync_depth | `1` | Sets the --depth argument value for the git operations; this is set to 1 by default as you won't need the git history -rsync_checkout_tag | `false` | Is the ``:branch`` symbol containing a branch or a tag? +rsync_checkout | `branch` | Is the ``:branch`` symbol containing a branch, tag or revision? +rsync_checkout_tag | `false` | Is the ``:branch`` symbol containing a branch or a tag? ``Deprecated`` rsync_copy | `rsync --archive --acls --xattrs` | The command used to copy from remote cache to remote release rsync_target_dir | `.` | The local directory within ``:rsync_stage`` to clone to & deploy (useful if you want to keep cache of several branches/tags for instance) enable_git_submodules | `false` | Should we fetch submodules as well? diff --git a/lib/capistrano/rsync.rb b/lib/capistrano/rsync.rb index 9cbf1b2..5441853 100644 --- a/lib/capistrano/rsync.rb +++ b/lib/capistrano/rsync.rb @@ -8,9 +8,17 @@ # Sparse checkout allows to checkout only part of the repository set_if_empty :rsync_sparse_checkout, [] -# Sparse checkout allows to checkout only part of the repository +# Merely here for backward compatibility reasons set_if_empty :rsync_checkout_tag, false +# Option states what to checkout +set_if_empty :rsync_checkout, "branch" + +# To be somewhat backward compatible to the previous checkout_tag option +if fetch(:rsync_checkout_tag, false) + set :rsync_checkout, "tag" +end + # You may not need the whole history, put to false to get it whole set_if_empty :rsync_depth, 1 @@ -40,12 +48,24 @@ end rsync_target = lambda do - target = !!fetch(:rsync_checkout_tag, false) ? "tags/#{fetch(:branch)}" : "origin/#{fetch(:branch)}" + if fetch(:rsync_checkout) == "tag" + target = "tags/#{fetch(:branch)}" + elsif fetch(:rsync_checkout) == "revision" + target = fetch(:branch) + else + target = "origin/#{fetch(:branch)}" + end + target end rsync_branch = lambda do - branch = !!fetch(:rsync_checkout_tag, false) ? "tags/#{fetch(:branch)}" : fetch(:branch) + if fetch(:rsync_checkout) == "tag" + branch = "tags/#{fetch(:branch)}" + else + branch = fetch(:branch) + end + branch end From 445c1d9f75e3cd73b1474efd8049b77d6f97481d Mon Sep 17 00:00:00 2001 From: Lennart Weijl Date: Wed, 15 Jul 2015 17:20:32 +0200 Subject: [PATCH 2/3] Process the comments on the PR into the code. Added a changelog item and upped the version. --- CHANGELOG.md | 3 +++ lib/capistrano/rsync.rb | 16 ++++++++-------- lib/capistrano/rsync/version.rb | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29d939f..377ad5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.3.1 (Jul 15, 2015) +- Adds support for checking out revisions on top of tags and branches + ## 1.3.0 (Jul 2, 2015) - Refactored library to use run_locally and execute from Capistrano, so the output is uniformized & we exit on failed commands - Added some options as well (see README.md for complete list) diff --git a/lib/capistrano/rsync.rb b/lib/capistrano/rsync.rb index 5441853..3ade664 100644 --- a/lib/capistrano/rsync.rb +++ b/lib/capistrano/rsync.rb @@ -48,14 +48,14 @@ end rsync_target = lambda do - if fetch(:rsync_checkout) == "tag" - target = "tags/#{fetch(:branch)}" - elsif fetch(:rsync_checkout) == "revision" - target = fetch(:branch) - else - target = "origin/#{fetch(:branch)}" - end - + case fetch(:rsync_checkout) + when "tag" + target = "tags/#{fetch(:branch)}" + when "revision" + target = fetch(:branch) + else + target = "origin/#{fetch(:branch)}" + end target end diff --git a/lib/capistrano/rsync/version.rb b/lib/capistrano/rsync/version.rb index 95dd16e..3862f02 100644 --- a/lib/capistrano/rsync/version.rb +++ b/lib/capistrano/rsync/version.rb @@ -1,5 +1,5 @@ module Capistrano module Rsync - VERSION = "1.3.0" + VERSION = "1.3.1" end end From 8b16830ab0f4af9837ad6040fa3b3460bc7fdc5d Mon Sep 17 00:00:00 2001 From: Lennart Weijl Date: Wed, 15 Jul 2015 17:32:25 +0200 Subject: [PATCH 3/3] Changed version in changelog and version.rb to 1.3.3. Also stated in the changelog that rsync_checkout_tag is now deprecated. --- CHANGELOG.md | 4 ++-- lib/capistrano/rsync/version.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 377ad5e..e8e7f6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ -## 1.3.1 (Jul 15, 2015) -- Adds support for checking out revisions on top of tags and branches +## 1.3.3 (Jul 15, 2015) +- Adds support for checking out revisions on top of tags and branches (rsync_checkout_tag is now deprecated) ## 1.3.0 (Jul 2, 2015) - Refactored library to use run_locally and execute from Capistrano, so the output is uniformized & we exit on failed commands diff --git a/lib/capistrano/rsync/version.rb b/lib/capistrano/rsync/version.rb index 3862f02..db55334 100644 --- a/lib/capistrano/rsync/version.rb +++ b/lib/capistrano/rsync/version.rb @@ -1,5 +1,5 @@ module Capistrano module Rsync - VERSION = "1.3.1" + VERSION = "1.3.3" end end