gitlab-org--gitlab-foss/app/controllers/projects/refs_controller.rb

65 lines
1.7 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
class Projects::RefsController < Projects::ApplicationController
2013-04-14 12:08:16 +00:00
include ExtractsPath
include TreeHelper
2011-11-16 05:38:53 +00:00
around_action :allow_gitaly_ref_name_caching, only: [:logs_tree]
before_action :require_non_empty_project
before_action :validate_ref_id
before_action :assign_ref_vars
before_action :authorize_download_code!
2011-11-16 05:38:53 +00:00
def switch
respond_to do |format|
format.html do
new_path =
case params[:destination]
when "tree"
project_tree_path(@project, @id)
when "blob"
project_blob_path(@project, @id)
when "graph"
project_network_path(@project, @id, @options)
when "graphs"
project_graph_path(@project, @id)
when "find_file"
project_find_file_path(@project, @id)
when "graphs_commits"
commits_project_graph_path(@project, @id)
when "badges"
project_settings_ci_cd_path(@project, ref: @id)
else
project_commits_path(@project, @id)
end
2011-11-16 17:19:18 +00:00
2012-09-17 17:49:57 +00:00
redirect_to new_path
2012-01-29 19:30:03 +00:00
end
end
2011-11-16 17:19:18 +00:00
end
2012-07-10 19:52:38 +00:00
def logs_tree
tree_summary = ::Gitlab::TreeSummary.new(
@commit, @project, current_user,
path: @path, offset: params[:offset], limit: 25)
respond_to do |format|
format.html { render_404 }
format.json do
logs, next_offset = tree_summary.fetch_logs
response.headers["More-Logs-Offset"] = next_offset.to_s if next_offset
render json: logs
end
end
2012-07-10 19:52:38 +00:00
end
private
def validate_ref_id
return not_found! if params[:id].present? && params[:id] !~ Gitlab::PathRegex.git_reference_regex
end
2011-11-16 05:38:53 +00:00
end