Skip to content
This repository
Browse code

Merge pull request #67 from mattgodbolt/master

Preserves file permissions when retrieving
  • Loading branch information...
commit ef64ce1dda8df90fb1367bf1520dcda1de96bf46 2 parents d64fe49 + dff8dae
Matthew Foemmel authored

Showing 2 changed files with 20 additions and 1 deletion. Show diff stats Hide diff stats

  1. +1 1  lib/fig/retriever.rb
  2. +19 0 spec/retriever_spec.rb
2  lib/fig/retriever.rb
@@ -99,7 +99,7 @@ def copy(source, relpath)
99 99 if !File.exist?(target) || File.mtime(source) > File.mtime(target)
100 100 $stderr.puts "\033[32m+ [#{@config.name}/#{@config.version}] #{relpath}\033[0m"
101 101 FileUtils.mkdir_p(File.dirname(target))
102   - FileUtils.cp(source, target)
  102 + FileUtils.cp(source, target, :preserve => true)
103 103 end
104 104 @config.files << relpath if @config
105 105 end
19 spec/retriever_spec.rb
@@ -44,4 +44,23 @@
44 44 File.exist?(File.join(test_dir, "baz.txt")).should == false
45 45 end
46 46 end
  47 +
  48 + it "preserves executable bit" do
  49 + test_dir = "tmp/retrieve-test"
  50 + FileUtils.rm_rf(test_dir)
  51 + FileUtils.mkdir_p(test_dir)
  52 +
  53 + File.open("tmp/plain", 'w') {|f| f << "plain"}
  54 + File.open("tmp/executable", 'w') {|f| f << "executable"}
  55 + FileUtils.chmod(0755, "tmp/executable")
  56 +
  57 + r = Retriever.new(test_dir)
  58 + r.with_config("foo", "1.2.3") do
  59 + r.retrieve("tmp/plain", "plain")
  60 + r.retrieve("tmp/executable", "executable")
  61 +
  62 + File.stat(File.join(test_dir, "plain")).executable?.should == false
  63 + File.stat(File.join(test_dir, "executable")).executable?.should == true
  64 + end
  65 + end
47 66 end

0 comments on commit ef64ce1

Please sign in to comment.
Something went wrong with that request. Please try again.