diff options
Diffstat (limited to 'app')
10 files changed, 27 insertions, 31 deletions
diff --git a/app/graphql/types/merge_requests/mergeability_check_identifier_enum.rb b/app/graphql/types/merge_requests/mergeability_check_identifier_enum.rb index ac25c98941c..d5e63d9c9ca 100644 --- a/app/graphql/types/merge_requests/mergeability_check_identifier_enum.rb +++ b/app/graphql/types/merge_requests/mergeability_check_identifier_enum.rb @@ -11,7 +11,7 @@ module Types value identifier.upcase, value: identifier, - description: "Mergeability check identifier is #{identifier}." + description: check_class.description end end end diff --git a/app/services/merge_requests/mergeability/check_base_service.rb b/app/services/merge_requests/mergeability/check_base_service.rb index b8a275b6c32..8f8ba812246 100644 --- a/app/services/merge_requests/mergeability/check_base_service.rb +++ b/app/services/merge_requests/mergeability/check_base_service.rb @@ -4,15 +4,21 @@ module MergeRequests class CheckBaseService attr_reader :merge_request, :params + class_attribute :identifier, :description + + def self.identifier(new_identifier) + self.identifier = new_identifier + end + + def self.description(new_description) + self.description = new_description + end + def initialize(merge_request:, params:) @merge_request = merge_request @params = params end - def self.identifier - failure_reason - end - def skip? raise NotImplementedError end @@ -28,10 +34,6 @@ module MergeRequests private - def failure_reason - self.class.failure_reason - end - def success(**args) Gitlab::MergeRequests::Mergeability::CheckResult .success(payload: default_payload(args)) diff --git a/app/services/merge_requests/mergeability/check_broken_status_service.rb b/app/services/merge_requests/mergeability/check_broken_status_service.rb index ae637b4e19d..d432375c423 100644 --- a/app/services/merge_requests/mergeability/check_broken_status_service.rb +++ b/app/services/merge_requests/mergeability/check_broken_status_service.rb @@ -2,9 +2,8 @@ module MergeRequests module Mergeability class CheckBrokenStatusService < CheckBaseService - def self.failure_reason - :broken_status - end + identifier :broken_status + description 'Checks whether the merge request is broken' def execute if merge_request.broken? diff --git a/app/services/merge_requests/mergeability/check_ci_status_service.rb b/app/services/merge_requests/mergeability/check_ci_status_service.rb index 9c57e61b07d..5c1aaaaf885 100644 --- a/app/services/merge_requests/mergeability/check_ci_status_service.rb +++ b/app/services/merge_requests/mergeability/check_ci_status_service.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true + module MergeRequests module Mergeability class CheckCiStatusService < CheckBaseService - def self.failure_reason - :ci_must_pass - end + identifier :ci_must_pass + description 'Checks whether CI has passed' def execute return inactive unless merge_request.only_allow_merge_if_pipeline_succeeds? diff --git a/app/services/merge_requests/mergeability/check_conflict_status_service.rb b/app/services/merge_requests/mergeability/check_conflict_status_service.rb index c59b3efff31..b60bb0cecb5 100644 --- a/app/services/merge_requests/mergeability/check_conflict_status_service.rb +++ b/app/services/merge_requests/mergeability/check_conflict_status_service.rb @@ -3,9 +3,8 @@ module MergeRequests module Mergeability class CheckConflictStatusService < CheckBaseService - def self.failure_reason - :conflict - end + identifier :conflict + description 'Checks whether the merge request has a conflict' def execute if merge_request.can_be_merged? diff --git a/app/services/merge_requests/mergeability/check_discussions_status_service.rb b/app/services/merge_requests/mergeability/check_discussions_status_service.rb index 45b6f64762b..baff557299d 100644 --- a/app/services/merge_requests/mergeability/check_discussions_status_service.rb +++ b/app/services/merge_requests/mergeability/check_discussions_status_service.rb @@ -2,9 +2,8 @@ module MergeRequests module Mergeability class CheckDiscussionsStatusService < CheckBaseService - def self.failure_reason - :discussions_not_resolved - end + identifier :discussions_not_resolved + description 'Checks whether the merge request has open discussions' def execute return inactive unless merge_request.only_allow_merge_if_all_discussions_are_resolved? diff --git a/app/services/merge_requests/mergeability/check_draft_status_service.rb b/app/services/merge_requests/mergeability/check_draft_status_service.rb index 5bd5c7ab305..fc0254ebe3f 100644 --- a/app/services/merge_requests/mergeability/check_draft_status_service.rb +++ b/app/services/merge_requests/mergeability/check_draft_status_service.rb @@ -3,9 +3,8 @@ module MergeRequests module Mergeability class CheckDraftStatusService < CheckBaseService - def self.failure_reason - :draft_status - end + identifier :draft_status + description 'Checks whether the merge request is draft' def execute if merge_request.draft? diff --git a/app/services/merge_requests/mergeability/check_open_status_service.rb b/app/services/merge_requests/mergeability/check_open_status_service.rb index 587e7e7a08d..b9191a53ea3 100644 --- a/app/services/merge_requests/mergeability/check_open_status_service.rb +++ b/app/services/merge_requests/mergeability/check_open_status_service.rb @@ -3,9 +3,8 @@ module MergeRequests module Mergeability class CheckOpenStatusService < CheckBaseService - def self.failure_reason - :not_open - end + identifier :not_open + description 'Checks whether the merge request is open' def execute if merge_request.open? diff --git a/app/services/merge_requests/mergeability/check_rebase_status_service.rb b/app/services/merge_requests/mergeability/check_rebase_status_service.rb index 99fa111643d..e3f003d9299 100644 --- a/app/services/merge_requests/mergeability/check_rebase_status_service.rb +++ b/app/services/merge_requests/mergeability/check_rebase_status_service.rb @@ -3,9 +3,8 @@ module MergeRequests module Mergeability class CheckRebaseStatusService < CheckBaseService - def self.failure_reason - :need_rebase - end + identifier :need_rebase + description 'Checks whether the merge request needs to be rebased' def execute return inactive unless merge_request.project.ff_merge_must_be_possible? diff --git a/app/workers/merge_request_cleanup_refs_worker.rb b/app/workers/merge_request_cleanup_refs_worker.rb index db1a1e96997..36979e843ef 100644 --- a/app/workers/merge_request_cleanup_refs_worker.rb +++ b/app/workers/merge_request_cleanup_refs_worker.rb @@ -19,7 +19,7 @@ class MergeRequestCleanupRefsWorker def perform_work unless merge_request - logger.error('No existing merge request to be cleaned up.') + logger.info('No existing merge request to be cleaned up.') return end |