Skip to content

Commit

Permalink
Merge pull request moll#13 from lweijl/master
Browse files Browse the repository at this point in the history
Adds support for checking out revisions on top of tags and branches
  • Loading branch information
Bladrak committed Jul 15, 2015
2 parents e73aaa0 + 8b16830 commit 6fb54b8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 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
- Added some options as well (see README.md for complete list)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
26 changes: 23 additions & 3 deletions lib/capistrano/rsync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -40,12 +48,24 @@
end

rsync_target = lambda do
target = !!fetch(:rsync_checkout_tag, false) ? "tags/#{fetch(:branch)}" : "origin/#{fetch(:branch)}"
case fetch(:rsync_checkout)
when "tag"
target = "tags/#{fetch(:branch)}"
when "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

Expand Down
2 changes: 1 addition & 1 deletion lib/capistrano/rsync/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Capistrano
module Rsync
VERSION = "1.3.0"
VERSION = "1.3.3"
end
end

0 comments on commit 6fb54b8

Please sign in to comment.