2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
class Projects::RefsController < Projects::ApplicationController
|
|
|
|
include ExtractsPath
|
2015-09-11 14:41:01 +05:30
|
|
|
include TreeHelper
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
around_action :allow_gitaly_ref_name_caching, only: [:logs_tree]
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
before_action :require_non_empty_project
|
2015-10-24 18:46:33 +05:30
|
|
|
before_action :validate_ref_id
|
2015-09-11 14:41:01 +05:30
|
|
|
before_action :assign_ref_vars
|
|
|
|
before_action :authorize_download_code!
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2020-05-05 14:28:15 +05:30
|
|
|
before_action only: [:logs_tree] do
|
2020-05-24 23:13:21 +05:30
|
|
|
push_frontend_feature_flag(:vue_file_list_lfs_badge, default_enabled: true)
|
2020-05-05 14:28:15 +05:30
|
|
|
end
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
def switch
|
|
|
|
respond_to do |format|
|
|
|
|
format.html do
|
2015-09-11 14:41:01 +05:30
|
|
|
new_path =
|
|
|
|
case params[:destination]
|
|
|
|
when "tree"
|
2017-09-10 17:25:29 +05:30
|
|
|
project_tree_path(@project, @id)
|
2015-09-11 14:41:01 +05:30
|
|
|
when "blob"
|
2017-09-10 17:25:29 +05:30
|
|
|
project_blob_path(@project, @id)
|
2015-09-11 14:41:01 +05:30
|
|
|
when "graph"
|
2017-09-10 17:25:29 +05:30
|
|
|
project_network_path(@project, @id, @options)
|
2015-09-11 14:41:01 +05:30
|
|
|
when "graphs"
|
2017-09-10 17:25:29 +05:30
|
|
|
project_graph_path(@project, @id)
|
2016-01-14 18:37:52 +05:30
|
|
|
when "find_file"
|
2017-09-10 17:25:29 +05:30
|
|
|
project_find_file_path(@project, @id)
|
2015-09-11 14:41:01 +05:30
|
|
|
when "graphs_commits"
|
2017-09-10 17:25:29 +05:30
|
|
|
commits_project_graph_path(@project, @id)
|
2016-06-02 11:05:42 +05:30
|
|
|
when "badges"
|
2018-05-09 12:01:36 +05:30
|
|
|
project_settings_ci_cd_path(@project, ref: @id)
|
2015-09-11 14:41:01 +05:30
|
|
|
else
|
2017-09-10 17:25:29 +05:30
|
|
|
project_commits_path(@project, @id)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
|
|
|
|
redirect_to new_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def logs_tree
|
2020-05-24 23:13:21 +05:30
|
|
|
tree_summary = ::Gitlab::TreeSummary.new(
|
|
|
|
@commit, @project, current_user,
|
|
|
|
path: @path, offset: params[:offset], limit: 25)
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
respond_to do |format|
|
|
|
|
format.html { render_404 }
|
2018-03-17 18:26:18 +05:30
|
|
|
format.json do
|
2020-05-24 23:13:21 +05:30
|
|
|
logs, next_offset = tree_summary.fetch_logs
|
|
|
|
|
|
|
|
response.headers["More-Logs-Offset"] = next_offset if next_offset
|
|
|
|
|
|
|
|
render json: logs
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
# Deprecated due to https://gitlab.com/gitlab-org/gitlab/-/issues/36863
|
|
|
|
# Will be removed soon https://gitlab.com/gitlab-org/gitlab/-/merge_requests/29895
|
2018-11-20 20:47:30 +05:30
|
|
|
format.js do
|
2020-05-24 23:13:21 +05:30
|
|
|
@logs, _ = tree_summary.summarize
|
|
|
|
@more_log_url = more_url(tree_summary.next_offset) if tree_summary.more?
|
2018-11-20 20:47:30 +05:30
|
|
|
end
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2015-10-24 18:46:33 +05:30
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
def more_url(offset)
|
|
|
|
logs_file_project_ref_path(@project, @ref, @path, offset: offset)
|
|
|
|
end
|
|
|
|
|
2015-10-24 18:46:33 +05:30
|
|
|
def validate_ref_id
|
2017-09-10 17:25:29 +05:30
|
|
|
return not_found! if params[:id].present? && params[:id] !~ Gitlab::PathRegex.git_reference_regex
|
2015-10-24 18:46:33 +05:30
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|