Permalink
Browse files

Merge pull request #67 from mattgodbolt/master

Preserves file permissions when retrieving
  • Loading branch information...
2 parents d64fe49 + dff8dae commit ef64ce1dda8df90fb1367bf1520dcda1de96bf46 @mfoemmel committed Sep 28, 2011
Showing with 20 additions and 1 deletion.
  1. +1 −1 lib/fig/retriever.rb
  2. +19 −0 spec/retriever_spec.rb
View
2 lib/fig/retriever.rb
@@ -99,7 +99,7 @@ def copy(source, relpath)
if !File.exist?(target) || File.mtime(source) > File.mtime(target)
$stderr.puts "\033[32m+ [#{@config.name}/#{@config.version}] #{relpath}\033[0m"
FileUtils.mkdir_p(File.dirname(target))
- FileUtils.cp(source, target)
+ FileUtils.cp(source, target, :preserve => true)
end
@config.files << relpath if @config
end
View
19 spec/retriever_spec.rb
@@ -44,4 +44,23 @@
File.exist?(File.join(test_dir, "baz.txt")).should == false
end
end
+
+ it "preserves executable bit" do
+ test_dir = "tmp/retrieve-test"
+ FileUtils.rm_rf(test_dir)
+ FileUtils.mkdir_p(test_dir)
+
+ File.open("tmp/plain", 'w') {|f| f << "plain"}
+ File.open("tmp/executable", 'w') {|f| f << "executable"}
+ FileUtils.chmod(0755, "tmp/executable")
+
+ r = Retriever.new(test_dir)
+ r.with_config("foo", "1.2.3") do
+ r.retrieve("tmp/plain", "plain")
+ r.retrieve("tmp/executable", "executable")
+
+ File.stat(File.join(test_dir, "plain")).executable?.should == false
+ File.stat(File.join(test_dir, "executable")).executable?.should == true
+ end
+ end
end

0 comments on commit ef64ce1

Please sign in to comment.