diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-24 06:11:32 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-24 06:11:32 +0000 |
commit | ea8c11261522bda899f8b5e5ac61a6324e2904ba (patch) | |
tree | e7d362607d096c831fcc009bd7739846230b464a /app | |
parent | a0d18c1c5c8c6257ff377416c0d86390f2601301 (diff) | |
download | gitlab-ce-ea8c11261522bda899f8b5e5ac61a6324e2904ba.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/graphql/types/ci/job_type.rb | 4 | ||||
-rw-r--r-- | app/models/ci/pipeline.rb | 4 | ||||
-rw-r--r-- | app/models/merge_request.rb | 16 | ||||
-rw-r--r-- | app/serializers/merge_request_widget_entity.rb | 2 |
4 files changed, 23 insertions, 3 deletions
diff --git a/app/graphql/types/ci/job_type.rb b/app/graphql/types/ci/job_type.rb index ba463cdd9c1..c86337eea89 100644 --- a/app/graphql/types/ci/job_type.rb +++ b/app/graphql/types/ci/job_type.rb @@ -18,6 +18,10 @@ module Types description: 'Schedule for the build.' field :artifacts, Types::Ci::JobArtifactType.connection_type, null: true, description: 'Artifacts generated by the job.' + field :finished_at, Types::TimeType, null: true, + description: 'When a job has finished running.' + field :duration, GraphQL::INT_TYPE, null: true, + description: 'Duration of the job in seconds.' def pipeline Gitlab::Graphql::Loaders::BatchModelLoader.new(::Ci::Pipeline, object.pipeline_id).find diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 3be107ea2e1..359012f3acb 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -1165,6 +1165,10 @@ module Ci end end + def for_merged_result? + merge_request_event_type == :merged_result + end + def persistent_ref @persistent_ref ||= PersistentRef.new(pipeline: self) end diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 097a6500804..7b8c4e844d4 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -36,6 +36,10 @@ class MergeRequest < ApplicationRecord SORTING_PREFERENCE_FIELD = :merge_requests_sort + ALLOWED_TO_USE_MERGE_BASE_PIPELINE_FOR_COMPARISON = { + 'Ci::CompareCodequalityReportsService' => ->(project) { ::Gitlab::Ci::Features.display_codequality_backend_comparison?(project) } + }.freeze + belongs_to :target_project, class_name: "Project" belongs_to :source_project, class_name: "Project" belongs_to :merge_user, class_name: "User" @@ -1564,7 +1568,7 @@ class MergeRequest < ApplicationRecord def compare_reports(service_class, current_user = nil, report_type = nil ) with_reactive_cache(service_class.name, current_user&.id, report_type) do |data| unless service_class.new(project, current_user, id: id, report_type: report_type) - .latest?(base_pipeline, actual_head_pipeline, data) + .latest?(comparison_base_pipeline(service_class.name), actual_head_pipeline, data) raise InvalidateReactiveCache end @@ -1600,7 +1604,7 @@ class MergeRequest < ApplicationRecord raise NameError, service_class unless service_class < Ci::CompareReportsBaseService current_user = User.find_by(id: current_user_id) - service_class.new(project, current_user, id: id, report_type: report_type).execute(base_pipeline, actual_head_pipeline) + service_class.new(project, current_user, id: id, report_type: report_type).execute(comparison_base_pipeline(identifier), actual_head_pipeline) end def all_commits @@ -1724,6 +1728,14 @@ class MergeRequest < ApplicationRecord end end + def use_merge_base_pipeline_for_comparison?(service_class) + ALLOWED_TO_USE_MERGE_BASE_PIPELINE_FOR_COMPARISON[service_class]&.call(project) + end + + def comparison_base_pipeline(service_class) + (use_merge_base_pipeline_for_comparison?(service_class) && merge_base_pipeline) || base_pipeline + end + def base_pipeline @base_pipeline ||= project.ci_pipelines .order(id: :desc) diff --git a/app/serializers/merge_request_widget_entity.rb b/app/serializers/merge_request_widget_entity.rb index 560dd2ea08b..6e69e7f370d 100644 --- a/app/serializers/merge_request_widget_entity.rb +++ b/app/serializers/merge_request_widget_entity.rb @@ -157,7 +157,7 @@ class MergeRequestWidgetEntity < Grape::Entity end def use_merge_base_with_merged_results? - object.actual_head_pipeline&.merge_request_event_type == :merged_result + object.actual_head_pipeline&.for_merged_result? end def head_pipeline_downloadable_path_for_report_type(file_type) |