[refs #385] zip archive
This commit is contained in:
parent
d2612e63b6
commit
770030e180
|
@ -814,3 +814,9 @@ div#git_help_data p {
|
|||
.center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.zip {
|
||||
float: left;
|
||||
margin-left: 5px;
|
||||
margin-top: 11px;
|
||||
}
|
||||
|
|
|
@ -86,6 +86,16 @@ class ProjectsController < ApplicationController
|
|||
redirect_to projects_path
|
||||
end
|
||||
|
||||
def archive
|
||||
treeish = params[:treeish].presence || @project.default_branch
|
||||
format = params[:format] || 'zip'
|
||||
file = Tempfile.new(treeish, 'tmp')
|
||||
system("cd #{@project.path}; git archive --format=#{format} -o #{file.path} #{treeish} >> /dev/null 2>&1")
|
||||
file.close
|
||||
send_file file.path, :disposition => 'attachment', :type => "application/#{format == 'tar' ? 'x-tar' : 'zip'}",
|
||||
:filename => "#{@project.owner.uname}-#{@project.name}-#{treeish}.#{format}"
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def prepare_list(projects)
|
||||
|
|
|
@ -61,6 +61,7 @@ class Ability
|
|||
can(:destroy, Project) {|project| owner? project}
|
||||
can(:destroy, Project) {|project| project.owner_type == 'Group' and project.owner.objects.exists?(:object_type => 'User', :object_id => user.id, :role => 'admin')}
|
||||
can :remove_user, Project
|
||||
can :archive, Project
|
||||
|
||||
can [:read, :owned], BuildList, :user_id => user.id
|
||||
can [:read, :related], BuildList, :project => {:owner_type => 'User', :owner_id => user.id}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
.description-top
|
||||
.zip= link_to "ZIP", archive_path(project.id, 'zip', @treeish)
|
||||
|
||||
= text_field_tag :url, git_repo_url(project.git_repo_name), :class => 'name', :spellcheck => 'false', :readonly => true
|
||||
.git_help ?
|
||||
.role= can?(:write, project) ? t("layout.read_write_access") : t("layout.read_access")
|
||||
|
|
|
@ -154,6 +154,8 @@ Rosa::Application.routes.draw do
|
|||
# Raw
|
||||
get '/projects/:project_id/raw/:treeish/*path' => "git/blobs#raw", :defaults => {:treeish => :master}, :as => :raw, :format => false
|
||||
|
||||
get '/projects/:id/archive/:format/tree/:treeish' => "projects#archive", :defaults => {:treeish => :master}, :as => :archive, :format => /zip|tar/
|
||||
|
||||
# Core callbacks
|
||||
match 'build_lists/publish_build', :to => "build_lists#publish_build"
|
||||
match 'build_lists/status_build', :to => "build_lists#status_build"
|
||||
|
|
Loading…
Reference in New Issue