Bladrak/capistrano-rsync

Configuring if checking out a revision or not

Closed this issue · 3 comments

Hi there,

I am having trouble integrating capistrano-rsync in our deployment process. We sometimes want to deploy a tag and sometimes deploy a branch, both are supported and work well. But when we want to deploy a specific revision, there seems to be no simple way of doing this.

Looking at rsync.rb

rsync_target = lambda do
  target = !!fetch(:rsync_checkout_tag, false) ? "tags/#{fetch(:branch)}" : "origin/#{fetch(:branch)}"
  target
end

rsync_branch = lambda do
  branch = !!fetch(:rsync_checkout_tag, false) ? "tags/#{fetch(:branch)}" : fetch(:branch)
  branch
end

...

execute :git, :reset, '--quiet', '--hard', "#{rsync_target.call}"

Both the tags and origin statements are hardcoded, but for a revision this is where it breaks.

Hopefully the following example makes it more clear.

cd tmp/my-project/deploy && /usr/bin/env git reset --quiet --hard origin/1e7762bf60ab3694ec746d7f46623cb54278aacb

Should be something like this..

cd tmp/my-project/deploy && /usr/bin/env git reset --quiet --hard 1e7762bf60ab3694ec746d7f46623cb54278aacb

Is this a known issue or is there a fix I am overlooking?

Hello @lweijl ! This is actually a use case we didn't encounter before, so we didn't develop the feature. But feel free to submit a PR with it, I'll be glad to review and merge it!

@Bladrak I am not much of a Ruby programmer, so if the code needs improvement please state this out and I will do my best in fixing that!

Thanks.

Fixed in #13