Commit 52344221 authored by mfluharty's avatar mfluharty

Cleanup according to feedback

Remove licensed report check outside EE
Since code quality should be the only accessible report here anyway

Use source branch and diff base shas
Instead of base and head pipeline shas
parent bead8e6a
......@@ -299,12 +299,6 @@ module Ci
project: [merge_request.source_project, merge_request.target_project])
end
# This structure describes feature levels
# to access the file types for given reports
REPORT_LICENSED_FEATURES = {
codequality: nil
}.freeze
# Returns the pipelines in descending order (= newest first), optionally
# limited to a number of references.
#
......@@ -631,8 +625,6 @@ module Ci
end
def batch_lookup_report_artifact_for_file_type(file_type)
return unless available_licensed_report_type?(file_type)
latest_report_artifacts
.values_at(*::Ci::JobArtifact.associated_file_types_for(file_type.to_s))
.flatten
......@@ -664,11 +656,6 @@ module Ci
end
end
def available_licensed_report_type?(file_type)
feature_names = REPORT_LICENSED_FEATURES.fetch(file_type)
feature_names.nil? || feature_names.any? { |feature| project.feature_available?(feature) }
end
def has_kubernetes_active?
project.deployment_platform&.active?
end
......
......@@ -86,12 +86,12 @@ class MergeRequestWidgetEntity < Grape::Entity
end
expose :blob_path do
expose :head_path, if: -> (mr, _) { mr.head_pipeline_sha } do |merge_request|
project_blob_path(merge_request.project, merge_request.head_pipeline_sha)
expose :head_path, if: -> (mr, _) { mr.source_branch_sha } do |merge_request|
project_blob_path(merge_request.project, merge_request.source_branch_sha)
end
expose :base_path, if: -> (mr, _) { mr.base_pipeline_sha } do |merge_request|
project_blob_path(merge_request.project, merge_request.base_pipeline_sha)
expose :base_path, if: -> (mr, _) { mr.diff_base_sha } do |merge_request|
project_blob_path(merge_request.project, merge_request.diff_base_sha)
end
end
......
......@@ -91,6 +91,16 @@ module EE
!merge_train_pipeline? && super
end
def batch_lookup_report_artifact_for_file_type(file_type)
return unless available_licensed_report_type?(file_type)
latest_report_artifacts
.values_at(*::Ci::JobArtifact.associated_file_types_for(file_type.to_s))
.flatten
.compact
.last
end
def expose_license_scanning_data?
batch_lookup_report_artifact_for_file_type(:license_scanning).present?
end
......@@ -163,6 +173,11 @@ module EE
def merge_train_ref?
::MergeRequest.merge_train_ref?(ref)
end
def available_licensed_report_type?(file_type)
feature_names = REPORT_LICENSED_FEATURES.fetch(file_type)
feature_names.nil? || feature_names.any? { |feature| project.feature_available?(feature) }
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment