2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
# Controller for viewing a file's blame
|
|
|
|
class Projects::BlameController < Projects::ApplicationController
|
|
|
|
include ExtractsPath
|
2019-12-26 22:10:19 +05:30
|
|
|
include RedirectsForMissingPathOnTree
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
before_action :require_non_empty_project
|
|
|
|
before_action :assign_ref_vars
|
|
|
|
before_action :authorize_download_code!
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
feature_category :source_code_management
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
def show
|
2015-09-11 14:41:01 +05:30
|
|
|
@blob = @repository.blob_at(@commit.id, @path)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
unless @blob
|
|
|
|
return redirect_to_tree_root_for_missing_path(@project, @ref, @path)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit }
|
2020-03-13 15:44:24 +05:30
|
|
|
environment_params[:find_latest] = true
|
2021-06-08 01:23:25 +05:30
|
|
|
@environment = ::Environments::EnvironmentsByDeploymentsFinder.new(@project, current_user, environment_params).execute.last
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
@blame = Gitlab::Blame.new(@blob, @commit)
|
|
|
|
@blame = Gitlab::View::Presenter::Factory.new(@blame, project: @project, path: @path).fabricate!
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|