capistrano-shared-file 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/lib/capistrano/shared_file/tasks.rb +23 -6
- data/lib/capistrano/shared_file/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ab5fabc8685d9f182a0389d306d19fdd6051b12
|
4
|
+
data.tar.gz: 65055df25ad30bf44ebdf7108f5ea22817eb768f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c86880a68661a0f00cd365569a26cdf1336f4ed4bbeac903d6649655140a8bccfbb4287ffff5d4d77744a2cf6a8406e3a77b4614fe9032554a7088de0624af59
|
7
|
+
data.tar.gz: 577355b64ae96d712ca29a1cf79da548008f48a929436f242a65bd19043e184f9c70052c1c0b8b0d9632072aedf6ef3935f3d4b90bcf04690ca04d1d54d94233
|
data/README.md
CHANGED
@@ -59,6 +59,14 @@ Enbales backups of your shared files when uploading and downloading shared files
|
|
59
59
|
|
60
60
|
For more details on the implications of setting this variable to `true`, refer to the next **Upload** and **Download** sections.
|
61
61
|
|
62
|
+
### shared_file_show_upload_diff
|
63
|
+
|
64
|
+
When set, you will be prompted with the diff of any files that are changing due to your shared_file:upload. By default:
|
65
|
+
|
66
|
+
set :shared_file_show_upload_diff, true
|
67
|
+
|
68
|
+
For more details on the implications of setting this variable to `true`, refer to the next **Upload** section.
|
69
|
+
|
62
70
|
## Tasks
|
63
71
|
|
64
72
|
### Upload
|
@@ -71,6 +79,10 @@ With backup (it creates a backup of the remote shared files on your machine befo
|
|
71
79
|
|
72
80
|
bundle exec cap shared_file:upload -S shared_file_backup=true
|
73
81
|
|
82
|
+
With show upload diff (downloads the existing file and displays the diff, prompting you to accept the changes):
|
83
|
+
|
84
|
+
bundle exec cap shared_file:upload -S shared_file_show_upload_diff=true
|
85
|
+
|
74
86
|
### Download
|
75
87
|
|
76
88
|
To download all the files defined in the `shared_files` capistrano variable from a remote server, you can execute:
|
@@ -6,9 +6,10 @@ end
|
|
6
6
|
|
7
7
|
Capistrano::Configuration.instance.load do
|
8
8
|
|
9
|
-
_cset :shared_files,
|
10
|
-
_cset :shared_file_dir,
|
11
|
-
_cset :shared_file_backup,
|
9
|
+
_cset :shared_files, %w(config/database.yml)
|
10
|
+
_cset :shared_file_dir, 'files'
|
11
|
+
_cset :shared_file_backup, false
|
12
|
+
_cset :shared_file_show_upload_diff, true
|
12
13
|
|
13
14
|
def remote_path_to(file)
|
14
15
|
File.join(shared_path, shared_file_dir, file)
|
@@ -18,6 +19,17 @@ Capistrano::Configuration.instance.load do
|
|
18
19
|
File.join(File.dirname(file), "#{Time.now.strftime('%Y%m%dT%H%M%S')}_#{File.basename(file)}")
|
19
20
|
end
|
20
21
|
|
22
|
+
def confirm_upload_is_desired(backup_file, file)
|
23
|
+
diff_result = `git diff --no-index --color=always --ignore-space-at-eol #{backup_file} #{file}`
|
24
|
+
File.unlink(backup_file) unless shared_file_backup
|
25
|
+
unless $?.success?
|
26
|
+
puts "Showing diff for #{file}:"
|
27
|
+
puts diff_result
|
28
|
+
result = Capistrano::CLI.ui.ask("Are you sure that you want to upload your changes to #{file} (y/n)?", ['y','n'])
|
29
|
+
return (result == 'y')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
21
33
|
namespace :shared_file do
|
22
34
|
|
23
35
|
desc 'Generate remote directories for shared files.'
|
@@ -32,10 +44,15 @@ Capistrano::Configuration.instance.load do
|
|
32
44
|
desc 'Upload shared files to server'
|
33
45
|
task :upload, :except => { :no_release => true } do
|
34
46
|
shared_files.each do |file|
|
35
|
-
if shared_file_backup
|
36
|
-
|
47
|
+
if shared_file_backup || shared_file_show_upload_diff
|
48
|
+
backup_file = backup_path_to(file)
|
49
|
+
top.download(remote_path_to(file), backup_file, :via => :scp)
|
50
|
+
if shared_file_show_upload_diff
|
51
|
+
should_upload = confirm_upload_is_desired(backup_file, file)
|
52
|
+
puts "No changes made to #{file}!"
|
53
|
+
end
|
37
54
|
end
|
38
|
-
top.upload(file, remote_path_to(file), :via => :scp)
|
55
|
+
top.upload(file, remote_path_to(file), :via => :scp) if !shared_file_show_upload_diff || should_upload
|
39
56
|
end
|
40
57
|
end
|
41
58
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-shared-file
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Salmeron Amselem
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -66,3 +66,4 @@ signing_key:
|
|
66
66
|
specification_version: 4
|
67
67
|
summary: Capistrano recipe to upload, download and symlink shared files.
|
68
68
|
test_files: []
|
69
|
+
has_rdoc:
|