2018-09-25 23:45:43 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2012-09-17 13:36:13 -04:00
|
|
|
# Controller for viewing a file's blame
|
2013-06-23 12:47:22 -04:00
|
|
|
class Projects::BlameController < Projects::ApplicationController
|
2012-09-20 13:55:14 -04:00
|
|
|
include ExtractsPath
|
2019-10-21 14:06:29 -04:00
|
|
|
include RedirectsForMissingPathOnTree
|
2012-09-17 13:36:13 -04:00
|
|
|
|
2015-04-16 08:03:37 -04:00
|
|
|
before_action :require_non_empty_project
|
|
|
|
before_action :assign_ref_vars
|
|
|
|
before_action :authorize_download_code!
|
2012-09-17 13:36:13 -04:00
|
|
|
|
|
|
|
def show
|
2015-08-10 12:55:03 -04:00
|
|
|
@blob = @repository.blob_at(@commit.id, @path)
|
2017-03-14 13:58:52 -04:00
|
|
|
|
2019-10-21 14:06:29 -04:00
|
|
|
unless @blob
|
|
|
|
return redirect_to_tree_root_for_missing_path(@project, @ref, @path)
|
|
|
|
end
|
2016-12-16 10:10:04 -05:00
|
|
|
|
2017-03-14 13:58:52 -04:00
|
|
|
environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit }
|
2019-12-18 13:08:04 -05:00
|
|
|
environment_params[:find_latest] = true
|
2017-03-14 13:58:52 -04:00
|
|
|
@environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last
|
|
|
|
|
2016-01-28 08:49:21 -05:00
|
|
|
@blame_groups = Gitlab::Blame.new(@blob, @commit).groups
|
2012-09-17 13:36:13 -04:00
|
|
|
end
|
|
|
|
end
|