diff options
author | Dmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com> | 2012-06-13 10:03:53 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com> | 2012-06-13 10:03:53 +0400 |
commit | a243253b10244e8a3b62c40b686b52ac61a3adc8 (patch) | |
tree | 73f84c11c9591e3ad3b434d5c962367802277c69 /app/roles/repository.rb | |
parent | edd81a79c5c2a61e565664cfa787185c4e19729b (diff) |
Refactored project archive. Improved MR usability formv2.6.0pre
Diffstat (limited to 'app/roles/repository.rb')
-rw-r--r-- | app/roles/repository.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/roles/repository.rb b/app/roles/repository.rb index 85ed6b7baaa..f61c77827e3 100644 --- a/app/roles/repository.rb +++ b/app/roles/repository.rb @@ -117,4 +117,28 @@ module Repository def root_ref? branch root_ref == branch end + + # Archive Project to .tar.gz + # + # Already packed repo archives stored at + # app_root/tmp/repositories/project_name/project_name-commit-id.tag.gz + # + def archive_repo ref + ref = ref || self.root_ref + commit = self.commit(ref) + return nil unless commit + + # Build file path + file_name = self.code + "-" + commit.id.to_s + ".tar.gz" + storage_path = File.join(Rails.root, "tmp", "repositories", self.code) + file_path = File.join(storage_path, file_name) + + # Create file if not exists + unless File.exists?(file_path) + FileUtils.mkdir_p storage_path + file = self.repo.archive_to_file(ref, nil, file_path) + end + + file_path + end end |