diff options
Diffstat (limited to 'app/services/merge_requests')
6 files changed, 23 insertions, 24 deletions
diff --git a/app/services/merge_requests/after_create_service.rb b/app/services/merge_requests/after_create_service.rb index d2c83f82ff8..93a0d375b97 100644 --- a/app/services/merge_requests/after_create_service.rb +++ b/app/services/merge_requests/after_create_service.rb @@ -5,9 +5,8 @@ module MergeRequests include Gitlab::Utils::StrongMemoize def execute(merge_request) - prepare_for_mergeability(merge_request) if early_prepare_for_mergeability?(merge_request) + prepare_for_mergeability(merge_request) prepare_merge_request(merge_request) - mark_as_unchecked(merge_request) unless early_prepare_for_mergeability?(merge_request) end private @@ -15,7 +14,7 @@ module MergeRequests def prepare_for_mergeability(merge_request) create_pipeline_for(merge_request, current_user) merge_request.update_head_pipeline - mark_as_unchecked(merge_request) + check_mergeability(merge_request) end def prepare_merge_request(merge_request) @@ -26,11 +25,6 @@ module MergeRequests notification_service.new_merge_request(merge_request, current_user) - unless early_prepare_for_mergeability?(merge_request) - create_pipeline_for(merge_request, current_user) - merge_request.update_head_pipeline - end - merge_request.diffs(include_stats: false).write_cache merge_request.create_cross_references!(current_user) @@ -49,14 +43,13 @@ module MergeRequests LinkLfsObjectsService.new(project: merge_request.target_project).execute(merge_request) end - def early_prepare_for_mergeability?(merge_request) - strong_memoize("early_prepare_for_mergeability_#{merge_request.target_project_id}".to_sym) do - Feature.enabled?(:early_prepare_for_mergeability, merge_request.target_project) - end - end + def check_mergeability(merge_request) + return unless merge_request.preparing? - def mark_as_unchecked(merge_request) - merge_request.mark_as_unchecked if merge_request.preparing? + # Need to set to unchecked to be able to check for mergeability or else + # it'll be a no-op. + merge_request.mark_as_unchecked + merge_request.check_mergeability(async: true) end end end diff --git a/app/services/merge_requests/base_service.rb b/app/services/merge_requests/base_service.rb index b0d0c32abd1..3363fc90997 100644 --- a/app/services/merge_requests/base_service.rb +++ b/app/services/merge_requests/base_service.rb @@ -246,7 +246,9 @@ module MergeRequests def remove_all_attention_requests(merge_request) return unless merge_request.attention_requested_enabled? - ::MergeRequests::BulkRemoveAttentionRequestedService.new(project: merge_request.project, current_user: current_user, merge_request: merge_request).execute + users = merge_request.reviewers + merge_request.assignees + + ::MergeRequests::BulkRemoveAttentionRequestedService.new(project: merge_request.project, current_user: current_user, merge_request: merge_request, users: users.uniq).execute end def remove_attention_requested(merge_request, user) diff --git a/app/services/merge_requests/bulk_remove_attention_requested_service.rb b/app/services/merge_requests/bulk_remove_attention_requested_service.rb index dd2ff741ba6..6573b623779 100644 --- a/app/services/merge_requests/bulk_remove_attention_requested_service.rb +++ b/app/services/merge_requests/bulk_remove_attention_requested_service.rb @@ -3,20 +3,24 @@ module MergeRequests class BulkRemoveAttentionRequestedService < MergeRequests::BaseService attr_accessor :merge_request + attr_accessor :users - def initialize(project:, current_user:, merge_request:) + def initialize(project:, current_user:, merge_request:, users:) super(project: project, current_user: current_user) @merge_request = merge_request + @users = users end + # rubocop: disable CodeReuse/ActiveRecord def execute return error("Invalid permissions") unless can?(current_user, :update_merge_request, merge_request) - merge_request.merge_request_assignees.update_all(state: :reviewed) - merge_request.merge_request_reviewers.update_all(state: :reviewed) + merge_request.merge_request_assignees.where(user_id: users).update_all(state: :reviewed) + merge_request.merge_request_reviewers.where(user_id: users).update_all(state: :reviewed) success end + # rubocop: enable CodeReuse/ActiveRecord end end diff --git a/app/services/merge_requests/mergeability_check_service.rb b/app/services/merge_requests/mergeability_check_service.rb index 3e294aeaa07..30531fcc17b 100644 --- a/app/services/merge_requests/mergeability_check_service.rb +++ b/app/services/merge_requests/mergeability_check_service.rb @@ -14,8 +14,8 @@ module MergeRequests def async_execute return service_error if service_error - return unless merge_request.mark_as_checking + merge_request.mark_as_checking MergeRequestMergeabilityCheckWorker.perform_async(merge_request.id) end diff --git a/app/services/merge_requests/rebase_service.rb b/app/services/merge_requests/rebase_service.rb index d1f45b4b49c..1c4e1784b34 100644 --- a/app/services/merge_requests/rebase_service.rb +++ b/app/services/merge_requests/rebase_service.rb @@ -2,7 +2,7 @@ module MergeRequests class RebaseService < MergeRequests::BaseService - REBASE_ERROR = 'Rebase failed. Please rebase locally' + REBASE_ERROR = 'Rebase failed: Rebase locally, resolve all conflicts, then push the branch.' attr_reader :merge_request, :rebase_error @@ -35,7 +35,7 @@ module MergeRequests def set_rebase_error(exception) @rebase_error = if exception.is_a?(Gitlab::Git::PreReceiveError) - "Something went wrong during the rebase pre-receive hook: #{exception.message}." + "The rebase pre-receive hook failed: #{exception.message}." else REBASE_ERROR end diff --git a/app/services/merge_requests/squash_service.rb b/app/services/merge_requests/squash_service.rb index 69b9740c2a5..f04682bf08a 100644 --- a/app/services/merge_requests/squash_service.rb +++ b/app/services/merge_requests/squash_service.rb @@ -9,9 +9,9 @@ module MergeRequests return success(squash_sha: merge_request.diff_head_sha) end - return error(s_('MergeRequests|This project does not allow squashing commits when merge requests are accepted.')) if squash_forbidden? + return error(s_("MergeRequests|Squashing not allowed: This project doesn't allow you to squash commits when merging.")) if squash_forbidden? - squash! || error(s_('MergeRequests|Failed to squash. Should be done manually.')) + squash! || error(s_('MergeRequests|Squashing failed: Squash the commits locally, resolve any conflicts, then push the branch.')) end private |