capistrano-rsync-bladrak 1.2.5 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c292534b215c3e190ddc2cf0d1679349778a1bb
4
- data.tar.gz: fca9478f8f74d08aecd1bdf47f8a116ad3829b08
3
+ metadata.gz: 807a60625c48a8eba047ac449acf315706156f32
4
+ data.tar.gz: 5959c263fb5d10d885f9d428ea6311a23e37a669
5
5
  SHA512:
6
- metadata.gz: cbde298a345a19d5866f21a3caa35c21fd8040e3cf543d8c6823468b95fe055432e0f9f95a9648de51ddf30ca4dd93268ab3625de447aa1152f11b9219870e79
7
- data.tar.gz: 0652255fa8aafd1ec57d96b5869f8ad6c0527023255a1b6ecc6a2707ca71e38519d4dbda267390673dca6d0d55b4c209ba8c14c601dcab8c34432a206638b26b
6
+ metadata.gz: 463245fbcbdf42fbac964dc248cb86f438fd55de05b2758c8619051df4f4703299fe20258e318c25646c4e61080c46f203820e64da78416c558b313b6abd31ef
7
+ data.tar.gz: 1cc5a61fb949f298f275272fc5e78f184bcf70e54009c4bf63797142ae3c7ab89b971bef3422ed9fbd20546b0f73d916642c6cd4dc7dde8731ae266a8d427d66
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.3.0 (Jul 2, 2015)
2
+ - Refactored library to use run_locally and execute from Capistrano, so the output is uniformized & we exit on failed commands
3
+ - Added some options as well (see README.md for complete list)
4
+ - [BC BREAK] Execution context may have changed, if you've overridden some options taking into account execution path for instance.
5
+
1
6
  ## 1.1.0 (Jan 17, 2015)
2
7
  - Added ``:rsync_sparse_checkout`` option
3
8
 
data/README.md CHANGED
@@ -1,13 +1,15 @@
1
1
  Capistrano::Rsync for Capistrano v3
2
2
  ===================================
3
3
 
4
- This repository is a fork of https://github.com/moll/capistrano-rsync which doesn't seem to be maintained anymore.
5
-
6
- It has all the capabilities of the original repo, and some other features. Moreover, I will try to maintain it.
4
+ [![Join the chat at https://gitter.im/Bladrak/capistrano-rsync](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Bladrak/capistrano-rsync?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
7
5
 
8
6
  [![Gem Version](https://badge.fury.io/rb/capistrano-rsync-bladrak.svg)](http://badge.fury.io/rb/capistrano-rsync-bladrak)
9
7
  [gem-badge]: https://badge.fury.io/rb/capistrano-rsync-bladrak.svg
10
8
 
9
+ This repository is a fork of https://github.com/moll/capistrano-rsync which doesn't seem to be maintained anymore.
10
+
11
+ It has all the capabilities of the original repo, and some other features. Moreover, I will try to maintain it.
12
+
11
13
  **Deploy with Rsync** to your server from any local (or remote) repository when
12
14
  using [**Capistrano**](http://www.capistranorb.com/). Saves you from having to
13
15
  install Git on your production machine and allows you to customize which files
@@ -42,9 +44,9 @@ Install with:
42
44
  gem install capistrano-rsync-bladrak
43
45
  ```
44
46
 
45
- Require it at the top of your `Capfile` (or `config/deploy.rb`):
46
- ```ruby
47
- require "capistrano/rsync"
47
+ Set rsync as the SCM to use
48
+ ```
49
+ set :scm, :rsync
48
50
  ```
49
51
 
50
52
  Set some `rsync_options` to your liking:
@@ -82,7 +84,7 @@ set :rsync_options, %w[
82
84
  ```
83
85
 
84
86
  ### Precompile assets before deploy
85
- Capistrano::Rsync runs `rsync:stage` before rsyncing. Hook to that like this:
87
+ Capistrano::Rsync runs `rsync:stage_done` before rsyncing. Hook to that like this:
86
88
  ```ruby
87
89
  task :precompile do
88
90
  Dir.chdir fetch(:rsync_stage) do
@@ -90,7 +92,7 @@ task :precompile do
90
92
  end
91
93
  end
92
94
 
93
- after "rsync:stage", "precompile"
95
+ after "rsync:stage_done", "precompile"
94
96
  ```
95
97
 
96
98
  ### Deploy release without symlinking the current directory
@@ -98,6 +100,23 @@ after "rsync:stage", "precompile"
98
100
  cap rsync:release
99
101
  ```
100
102
 
103
+ Troubleshooting
104
+ ---------------
105
+ If you need to hook after rsync:stage_done in your deploy.rb, the rsync namespace is not loaded yet.
106
+
107
+ So do it like this in your deploy.rb:
108
+ ```
109
+ namespace :rsync do
110
+ # Create an empty task to hook with. Implementation will be come next
111
+ task :stage_done
112
+
113
+ # Then add your hook
114
+ after :stage_done, :my_task do
115
+ # Do some stuff.
116
+ end
117
+ end
118
+ ```
119
+
101
120
 
102
121
  Configuration
103
122
  -------------
@@ -112,6 +131,10 @@ rsync_cache | `shared/deploy` | Path where to cache your repository on the ser
112
131
  rsync_options | `[]` | Array of options to pass to `rsync`.
113
132
  rsync_sparse_checkout | `[]` | Array of directories to checkout (checks out all if empty)
114
133
  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
134
+ rsync_checkout_tag | `false` | Is the ``:branch`` symbol containing a branch or a tag?
135
+ rsync_copy | `rsync --archive --acls --xattrs` | The command used to copy from remote cache to remote release
136
+ 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)
137
+ enable_git_submodules | `false` | Should we fetch submodules as well?
115
138
 
116
139
 
117
140
  License
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Rsync
3
- VERSION = "1.2.5"
3
+ VERSION = "1.3.0"
4
4
  end
5
5
  end
@@ -1,29 +1,30 @@
1
1
  require File.expand_path("../rsync/version", __FILE__)
2
2
 
3
- namespace :load do
4
- task :defaults do
3
+ set_if_empty :rsync_options, [
4
+ '--archive'
5
+ ]
6
+ set_if_empty :rsync_copy, "rsync --archive --acls --xattrs"
5
7
 
6
- set :rsync_options, []
7
- set :rsync_copy, "rsync --archive --acls --xattrs"
8
+ # Sparse checkout allows to checkout only part of the repository
9
+ set_if_empty :rsync_sparse_checkout, []
8
10
 
9
- # Sparse checkout allows to checkout only part of the repository
10
- set :rsync_sparse_checkout, []
11
+ # Sparse checkout allows to checkout only part of the repository
12
+ set_if_empty :rsync_checkout_tag, false
11
13
 
12
- # You may not need the whole history, put to false to get it whole
13
- set :rsync_depth, 1
14
+ # You may not need the whole history, put to false to get it whole
15
+ set_if_empty :rsync_depth, 1
14
16
 
15
- # Stage is used on your local machine for rsyncing from.
16
- set :rsync_stage, "tmp/deploy"
17
+ # Stage is used on your local machine for rsyncing from.
18
+ set_if_empty :rsync_stage, "tmp/deploy"
17
19
 
18
- # Cache is used on the server to copy files to from to the release directory.
19
- # Saves you rsyncing your whole app folder each time. If you nil rsync_cache,
20
- # Capistrano::Rsync will sync straight to the release path.
21
- set :rsync_cache, "shared/deploy"
20
+ # Cache is used on the server to copy files to from to the release directory.
21
+ # Saves you rsyncing your whole app folder each time. If you nil rsync_cache,
22
+ # Capistrano::Rsync will sync straight to the release path.
23
+ set_if_empty :rsync_cache, "shared/deploy"
22
24
 
23
- set :rsync_target_dir, ""
24
- end
25
- end
25
+ set_if_empty :rsync_target_dir, "."
26
26
 
27
+ set_if_empty :enable_git_submodules, false
27
28
 
28
29
  # NOTE: Please don't depend on tasks without a description (`desc`) as they
29
30
  # might change between minor or patch version releases. They make up the
@@ -41,19 +42,37 @@ rsync_target = lambda do
41
42
  target
42
43
  end
43
44
 
45
+ rsync_branch = lambda do
46
+ branch = !!fetch(:rsync_checkout_tag, false) ? "tags/#{fetch(:branch)}" : fetch(:branch)
47
+ branch
48
+ end
49
+
50
+ git_depth = lambda do
51
+ depth = !!fetch(:rsync_depth, false) ? "--depth=#{fetch(:rsync_depth)}" : ""
52
+ depth
53
+ end
54
+
55
+ git_depth_clone = lambda do
56
+ depth = !!fetch(:rsync_depth, false) ? "--depth=#{fetch(:rsync_depth)} --no-single-branch" : ""
57
+ depth
58
+ end
59
+
44
60
  Rake::Task["deploy:check"].enhance ["rsync:hook_scm"]
45
61
 
62
+ # Local -> Remote cache
46
63
  desc "Stage and rsync to the server (or its cache)."
47
- task :rsync => %w[rsync:stage] do
64
+ task :rsync => %w[rsync:stage_done] do
48
65
  on release_roles(:all) do |role|
49
66
  user = role.user + "@" if !role.user.nil?
50
67
 
51
- rsync = %w[rsync]
52
- rsync.concat fetch(:rsync_options)
53
- rsync << File.join(fetch(:rsync_stage), File.join(fetch(:rsync_target_dir), ""))
54
- rsync << "#{user}#{role.hostname}:#{rsync_cache.call || release_path}"
55
-
56
- Kernel.system *rsync
68
+ run_locally do
69
+ within fetch(:rsync_stage) do
70
+ execute :rsync,
71
+ fetch(:rsync_options),
72
+ fetch(:rsync_target_dir),
73
+ "#{user}#{role.hostname}:#{rsync_cache.call || release_path}"
74
+ end
75
+ end
57
76
  end
58
77
  end
59
78
 
@@ -94,74 +113,66 @@ namespace :rsync do
94
113
  end
95
114
  end
96
115
 
116
+ # Git first time -> Local
97
117
  task :create_stage do
98
118
  next if File.directory?(fetch(:rsync_stage))
99
119
  next if !has_roles?
100
120
 
101
121
  if fetch(:rsync_sparse_checkout, []).any?
102
- init = %W[git init --quiet]
103
- init << fetch(:rsync_stage)
104
-
105
- Kernel.system *init
106
-
107
- Dir.chdir fetch(:rsync_stage) do
108
- remote = %W[git remote add origin]
109
- remote << fetch(:repo_url)
110
- Kernel.system *remote
111
-
112
- fetch = %W[git fetch --quiet --prune --all -t]
113
- if !!fetch(:rsync_depth, false)
114
- fetch << "--depth=#{fetch(:rsync_depth)}"
115
- end
116
- Kernel.system *fetch
117
-
118
- sparse = %W[git config core.sparsecheckout true]
119
- Kernel.system *sparse
120
-
121
- sparse_dir = %W[mkdir .git/info]
122
- Kernel.system *sparse_dir
123
-
124
- open('.git/info/sparse-checkout', 'a') { |f|
125
- fetch(:rsync_sparse_checkout).each do |sparse_dir|
126
- f.puts sparse_dir
127
- end
128
- }
129
-
130
- pull = %W[git pull --quiet]
131
- if !!fetch(:rsync_depth, false)
132
- pull << "--depth=#{fetch(:rsync_depth)}"
122
+ run_locally do
123
+ execute :git, :init, '--quiet', fetch(:rsync_stage)
124
+ within fetch(:rsync_stage) do
125
+ execute :git, :remote, :add, :origin, fetch(:repo_url)
126
+
127
+ execute :git, :fetch, '--quiet --prune --all -t', "#{git_depth.call}"
128
+
129
+ execute :git, :config, 'core.sparsecheckout true'
130
+ execute :mkdir, '.git/info'
131
+ open(File.join(fetch(:rsync_stage), '.git/info/sparse-checkout'), 'a') { |f|
132
+ fetch(:rsync_sparse_checkout).each do |sparse_dir|
133
+ f.puts sparse_dir
134
+ end
135
+ }
136
+
137
+ execute :git, :pull, '--quiet', "#{git_depth.call}", :origin, "#{rsync_branch.call}"
133
138
  end
134
- pull << "origin"
135
- pull << rsync_target.call
136
- Kernel.system *pull
137
139
  end
138
140
  else
139
- clone = %W[git clone --quiet]
140
- clone << fetch(:repo_url, ".")
141
- clone << fetch(:rsync_stage)
142
- if !!fetch(:rsync_depth, false)
143
- clone << "--depth=#{fetch(:rsync_depth)}"
141
+ submodules = !!fetch(:enable_git_submodules) ? "--recursive" : ""
142
+ run_locally do
143
+ execute :git,
144
+ :clone,
145
+ '--quiet',
146
+ fetch(:repo_url),
147
+ fetch(:rsync_stage),
148
+ "#{git_depth_clone.call}",
149
+ "#{submodules}"
144
150
  end
145
- Kernel.system *clone
146
151
  end
147
152
  end
148
153
 
154
+ # Git update -> Local
149
155
  desc "Stage the repository in a local directory."
150
156
  task :stage => %w[create_stage] do
151
157
  next if !has_roles?
152
158
 
153
- Dir.chdir fetch(:rsync_stage) do
154
- update = %W[git fetch --quiet --all --prune]
155
- if !!fetch(:rsync_depth, false)
156
- update << "--depth=#{fetch(:rsync_depth)}"
157
- end
158
- Kernel.system *update
159
+ run_locally do
160
+ within fetch(:rsync_stage) do
161
+ tags = !!fetch(:rsync_checkout_tag, false) ? '--tags' : ''
162
+ execute :git, :fetch, '--quiet --all --prune', "#{tags}", "#{git_depth.call}"
163
+
164
+ execute :git, :reset, '--quiet', '--hard', "#{rsync_target.call}"
159
165
 
160
- checkout = %W[git reset --quiet --hard #{rsync_target.call}]
161
- Kernel.system *checkout
166
+ if fetch(:enable_git_submodules)
167
+ execute :git, :submodule, :update
168
+ end
169
+ end
162
170
  end
163
171
  end
164
172
 
173
+ task :stage_done => %w[stage]
174
+
175
+ # Remote Cache -> Remote Release
165
176
  desc "Copy the code to the releases directory."
166
177
  task :release => %w[rsync] do
167
178
  # Skip copying if we've already synced straight to the release directory.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-rsync-bladrak
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hugo Briand, Andri Möll
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-05 00:00:00.000000000 Z
11
+ date: 2015-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano