2018-09-26 03:45:43 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2012-09-17 17:36:13 +00:00
|
|
|
# Controller for viewing a file's blame
|
2013-06-23 16:47:22 +00:00
|
|
|
class Projects::BlameController < Projects::ApplicationController
|
2012-09-20 17:55:14 +00:00
|
|
|
include ExtractsPath
|
2019-10-21 18:06:29 +00:00
|
|
|
include RedirectsForMissingPathOnTree
|
2012-09-17 17:36:13 +00:00
|
|
|
|
2015-04-16 12:03:37 +00:00
|
|
|
before_action :require_non_empty_project
|
|
|
|
before_action :assign_ref_vars
|
|
|
|
before_action :authorize_download_code!
|
2012-09-17 17:36:13 +00:00
|
|
|
|
2020-10-08 18:08:32 +00:00
|
|
|
feature_category :source_code_management
|
2021-11-12 18:12:20 +00:00
|
|
|
urgency :low, [:show]
|
2020-10-08 18:08:32 +00:00
|
|
|
|
2012-09-17 17:36:13 +00:00
|
|
|
def show
|
2015-08-10 16:55:03 +00:00
|
|
|
@blob = @repository.blob_at(@commit.id, @path)
|
2017-03-14 17:58:52 +00:00
|
|
|
|
2019-10-21 18:06:29 +00:00
|
|
|
unless @blob
|
|
|
|
return redirect_to_tree_root_for_missing_path(@project, @ref, @path)
|
|
|
|
end
|
2016-12-16 15:10:04 +00:00
|
|
|
|
2017-03-14 17:58:52 +00:00
|
|
|
environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit }
|
2019-12-18 18:08:04 +00:00
|
|
|
environment_params[:find_latest] = true
|
2021-04-22 15:09:56 +00:00
|
|
|
@environment = ::Environments::EnvironmentsByDeploymentsFinder.new(@project, current_user, environment_params).execute.last
|
2017-03-14 17:58:52 +00:00
|
|
|
|
2022-09-13 12:12:50 +00:00
|
|
|
blame_service = Projects::BlameService.new(@blob, @commit, params.permit(:page, :no_pagination))
|
2022-05-17 15:09:01 +00:00
|
|
|
|
2022-06-21 03:08:34 +00:00
|
|
|
@blame = Gitlab::View::Presenter::Factory.new(blame_service.blame, project: @project, path: @path, page: blame_service.page).fabricate!
|
2022-09-21 15:14:09 +00:00
|
|
|
|
2022-09-13 12:12:50 +00:00
|
|
|
@blame_pagination = blame_service.pagination
|
2022-09-21 15:14:09 +00:00
|
|
|
|
|
|
|
@blame_per_page = blame_service.per_page
|
2012-09-17 17:36:13 +00:00
|
|
|
end
|
|
|
|
end
|
2021-11-19 09:13:48 +00:00
|
|
|
|
|
|
|
Projects::BlameController.prepend_mod
|