debian-mirror-gitlab/app/controllers/projects/repositories_controller.rb

41 lines
994 B
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
class Projects::RepositoriesController < Projects::ApplicationController
2018-05-09 12:01:36 +05:30
include ExtractsPath
2014-09-02 18:07:02 +05:30
# Authorize
2015-09-11 14:41:01 +05:30
before_action :require_non_empty_project, except: :create
2018-05-09 12:01:36 +05:30
before_action :assign_archive_vars, only: :archive
2015-09-11 14:41:01 +05:30
before_action :authorize_download_code!
before_action :authorize_admin_project!, only: :create
2014-09-02 18:07:02 +05:30
2015-04-26 12:48:37 +05:30
def create
@project.create_repository
redirect_to project_path(@project)
2014-09-02 18:07:02 +05:30
end
def archive
2018-05-09 12:01:36 +05:30
append_sha = params[:append_sha]
if @ref
shortname = "#{@project.path}-#{@ref.tr('/', '-')}"
append_sha = false if @filename == shortname
end
send_git_archive @repository, ref: @ref, format: params[:format], append_sha: append_sha
2015-10-24 18:46:33 +05:30
rescue => ex
logger.error("#{self.class.name}: #{ex}")
return git_not_found!
2014-09-02 18:07:02 +05:30
end
2018-05-09 12:01:36 +05:30
def assign_archive_vars
if params[:id]
@ref, @filename = extract_ref(params[:id])
else
@ref = params[:ref]
@filename = nil
end
rescue InvalidPathError
render_404
end
2014-09-02 18:07:02 +05:30
end