diff options
author | Johan Sørensen <johan@johansorensen.com> | 2009-09-07 17:19:37 +0200 |
---|---|---|
committer | Johan Sørensen <johan@johansorensen.com> | 2009-09-07 17:19:37 +0200 |
commit | 95bf061616a3c640d55ebb533068b2842a5d43ea (patch) | |
tree | 9d180ada1997bd34a44fc5a87be47e8cc7f8906e | |
parent | a3d4edc10efeab63814b9f0f38151bf06b94e4f1 (diff) | |
download | gitorious-mainline-outdated-95bf061616a3c640d55ebb533068b2842a5d43ea.zip gitorious-mainline-outdated-95bf061616a3c640d55ebb533068b2842a5d43ea.tar.gz gitorious-mainline-outdated-95bf061616a3c640d55ebb533068b2842a5d43ea.tar.bz2 |
Make sure tarballs are generated with a prefix
Otherwise we may litter a users directory with our junk
-rw-r--r-- | app/controllers/trees_controller.rb | 1 | ||||
-rw-r--r-- | app/processors/repository_archiving_processor.rb | 5 | ||||
-rw-r--r-- | test/unit/processors/repository_archiving_processor_test.rb | 4 |
3 files changed, 7 insertions, 3 deletions
diff --git a/app/controllers/trees_controller.rb b/app/controllers/trees_controller.rb index d13b067..cc5b4f3 100644 --- a/app/controllers/trees_controller.rb +++ b/app/controllers/trees_controller.rb @@ -106,6 +106,7 @@ class TreesController < ApplicationController :output_path => File.join(GitoriousConfig["archive_cache_dir"], disk_path), :work_path => File.join(GitoriousConfig["archive_work_dir"], disk_path), :commit_sha => commit.id, + :name => (repo.project.slug + "-" + repo.name), :format => "tar.gz", } publish :archive_repo, payload.to_json diff --git a/app/processors/repository_archiving_processor.rb b/app/processors/repository_archiving_processor.rb index db22008..a2e6d92 100644 --- a/app/processors/repository_archiving_processor.rb +++ b/app/processors/repository_archiving_processor.rb @@ -28,7 +28,8 @@ class RepositoryArchivingProcessor < ApplicationProcessor Dir.chdir(msg["full_repository_path"]) do case msg["format"] when "tar.gz" - run("git archive --format=tar #{e(msg['commit_sha'])} | gzip > #{e(msg['work_path'])}") + run("git archive --format=tar --prefix=#{e(msg['name'] || msg['commit_sha'])}/ " + + "#{e(msg['commit_sha'])} | gzip > #{e(msg['work_path'])}") end end @@ -49,4 +50,4 @@ class RepositoryArchivingProcessor < ApplicationProcessor def e(string) string.gsub("'", '').gsub('"', '') end -end
\ No newline at end of file +end diff --git a/test/unit/processors/repository_archiving_processor_test.rb b/test/unit/processors/repository_archiving_processor_test.rb index e6de44a..3c11461 100644 --- a/test/unit/processors/repository_archiving_processor_test.rb +++ b/test/unit/processors/repository_archiving_processor_test.rb @@ -29,6 +29,7 @@ class RepositoryArchivingProcessorTest < ActiveSupport::TestCase :output_path => "/tmp/output/foo.tar.gz", :work_path => "/tmp/work/foo.tar.gz", :commit_sha => "abc123", + :name => "ze_project-reponame", :format => "tar.gz", } end @@ -42,7 +43,8 @@ class RepositoryArchivingProcessorTest < ActiveSupport::TestCase should "generates an archived tarball in the work dir and moves it to the cache path" do File.expects(:exist?).with(@msg[:output_path]).returns(false) Dir.expects(:chdir).yields(Dir.new("/tmp")) - @processor.expects(:run).with("git archive --format=tar abc123 | gzip > #{@msg[:work_path]}").returns(nil) + @processor.expects(:run).with("git archive --format=tar " + + "--prefix=ze_project-reponame/ abc123 | gzip > #{@msg[:work_path]}").returns(nil) @processor.expects(:run_successful?).returns(true) FileUtils.expects(:mv).with(@msg[:work_path], @msg[:output_path]) |