public
Description: Remote multi-server automation tool. This repository is no longer being actively maintained. Please ask on the mailing list to find someone who has a well-maintained fork. Thanks!
Homepage: http://www.capify.org
Clone URL: git://github.com/jamis/capistrano.git
make sure :mode parameter to upload() is honored
Jamis Buck (author)
Thu May 29 14:16:04 -0700 2008
commit  9be48bd0b07a40272c9e9863615e21bf53deda6b
tree    266d7a5fffed4a397f15c069218428455e38e5a8
parent  c1e927989bccb4197f9877e2fa836a064712b5d7
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *unreleased*
0
 
0
+* If :mode is given to upload() helper, do a chmod after to set the mode [Jamis Buck]
0
+
0
 * Fix load_from_file method for windows users [Neil Wilson]
0
 
0
 * Display a deprecation error if a remote git branch is specified [Tim Harper]
...
10
11
12
13
14
15
16
...
23
24
25
 
26
 
 
 
 
27
28
29
...
10
11
12
 
13
14
15
...
22
23
24
25
26
27
28
29
30
31
32
33
0
@@ -10,7 +10,6 @@ module Capistrano
0
         # set the mode on the file.
0
         def put(data, path, options={})
0
           opts = options.dup
0
-          opts[:permissions] = opts.delete(:mode)
0
           upload(StringIO.new(data), path, opts)
0
         end
0
     
0
@@ -23,7 +22,12 @@ module Capistrano
0
         end
0
 
0
         def upload(from, to, options={}, &block)
0
+          mode = options.delete(:mode)
0
           transfer(:up, from, to, options, &block)
0
+          if mode
0
+            mode = mode.is_a?(Numeric) ? mode.to_s(8) : mode.to_s
0
+            run "chmod #{mode} #{to}"
0
+          end
0
         end
0
 
0
         def download(from, to, options={}, &block)
...
14
15
16
17
 
 
18
19
20
...
28
29
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
32
33
...
14
15
16
 
17
18
19
20
21
...
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
0
@@ -14,7 +14,8 @@ class ConfigurationActionsFileTransferTest < Test::Unit::TestCase
0
 
0
   def test_put_should_delegate_to_upload
0
     @config.expects(:upload).with { |from, to, opts|
0
-      from.string == "some data" && to == "test.txt" && opts == { :permissions => 0777 } }
0
+      from.string == "some data" && to == "test.txt" && opts == { :mode => 0777 } }
0
+    @config.expects(:run).never
0
     @config.put("some data", "test.txt", :mode => 0777)
0
   end
0
 
0
@@ -28,6 +29,24 @@ class ConfigurationActionsFileTransferTest < Test::Unit::TestCase
0
     @config.upload("testl.txt", "testr.txt", :foo => "bar")
0
   end
0
 
0
+  def test_upload_without_mode_should_not_try_to_chmod
0
+    @config.expects(:transfer).with(:up, "testl.txt", "testr.txt", :foo => "bar")
0
+    @config.expects(:run).never
0
+    @config.upload("testl.txt", "testr.txt", :foo => "bar")
0
+  end
0
+
0
+  def test_upload_with_mode_should_try_to_chmod
0
+    @config.expects(:transfer).with(:up, "testl.txt", "testr.txt", :foo => "bar")
0
+    @config.expects(:run).with("chmod 775 testr.txt")
0
+    @config.upload("testl.txt", "testr.txt", :mode => 0775, :foo => "bar")
0
+  end
0
+
0
+  def test_upload_with_symbolic_mode_should_try_to_chmod
0
+    @config.expects(:transfer).with(:up, "testl.txt", "testr.txt", :foo => "bar")
0
+    @config.expects(:run).with("chmod g+w testr.txt")
0
+    @config.upload("testl.txt", "testr.txt", :mode => "g+w", :foo => "bar")
0
+  end
0
+
0
   def test_download_should_delegate_to_transfer
0
     @config.expects(:transfer).with(:down, "testr.txt", "testl.txt", :foo => "bar")
0
     @config.download("testr.txt", "testl.txt", :foo => "bar")

Comments