diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-01 00:08:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-01 00:08:01 +0300 |
commit | d88cacce3f205151867ab3f9297f10cdae4a7025 (patch) | |
tree | a511ad558a92a66d0ad8ab635b99d16387be0d2d /app/models | |
parent | 9e7f94a7408534411dc8da69c9e3ad3a55722b51 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/pipeline.rb | 4 | ||||
-rw-r--r-- | app/models/ci/runner.rb | 5 | ||||
-rw-r--r-- | app/models/concerns/has_user_type.rb | 3 | ||||
-rw-r--r-- | app/models/namespace.rb | 7 | ||||
-rw-r--r-- | app/models/user.rb | 10 |
5 files changed, 12 insertions, 17 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 1f147266fee..ef23987918a 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -1340,13 +1340,15 @@ module Ci persistent_ref.create end + # For dependent bridge jobs we reset the upstream bridge recursively + # to reflect that a downstream pipeline is running again def reset_source_bridge!(current_user) # break recursion when no source_pipeline bridge (first upstream pipeline) return unless bridge_waiting? return unless current_user.can?(:update_pipeline, source_bridge.pipeline) source_bridge.pending! - Ci::AfterRequeueJobService.new(project, current_user).execute(source_bridge) # rubocop:disable CodeReuse/ServiceClass + Ci::ResetSkippedJobsService.new(project, current_user).execute(source_bridge) # rubocop:disable CodeReuse/ServiceClass end # EE-only diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index d3ceec7ae36..a7f3ff938c3 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -69,7 +69,6 @@ module Ci TAG_LIST_MAX_LENGTH = 50 has_many :builds - has_many :running_builds, inverse_of: :runner, class_name: 'Ci::RunningBuild' has_many :runner_projects, inverse_of: :runner, autosave: true, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_many :projects, through: :runner_projects, disable_joins: true has_many :runner_namespaces, inverse_of: :runner, autosave: true @@ -91,9 +90,7 @@ module Ci scope :with_recent_runner_queue, -> { where('contacted_at > ?', recent_queue_deadline) } scope :with_running_builds, -> do - where('EXISTS(?)', - ::Ci::RunningBuild.select(1) - .where('ci_running_builds.runner_id = ci_runners.id')) + where('EXISTS(?)', ::Ci::Build.running.select(1).where('ci_builds.runner_id = ci_runners.id')) end # BACKWARD COMPATIBILITY: There are needed to maintain compatibility with `AVAILABLE_SCOPES` used by `lib/api/runners.rb` diff --git a/app/models/concerns/has_user_type.rb b/app/models/concerns/has_user_type.rb index b5352db5a56..8e371f2a9c1 100644 --- a/app/models/concerns/has_user_type.rb +++ b/app/models/concerns/has_user_type.rb @@ -14,11 +14,10 @@ module HasUserType migration_bot: 7, security_bot: 8, automation_bot: 9, - security_policy_bot: 10, admin_bot: 11 }.with_indifferent_access.freeze - BOT_USER_TYPES = %w[alert_bot project_bot support_bot visual_review_bot migration_bot security_bot automation_bot security_policy_bot admin_bot].freeze + BOT_USER_TYPES = %w[alert_bot project_bot support_bot visual_review_bot migration_bot security_bot automation_bot admin_bot].freeze NON_INTERNAL_USER_TYPES = %w[human project_bot service_user].freeze INTERNAL_USER_TYPES = (USER_TYPES.keys - NON_INTERNAL_USER_TYPES).freeze diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 47fd39e8b96..35502b429d0 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -330,6 +330,13 @@ class Namespace < ApplicationRecord type.nil? || type == Namespaces::UserNamespace.sti_name || !(group_namespace? || project_namespace?) end + def bot_user_namespace? + return false unless user_namespace? + return false unless owner && owner.bot? + + true + end + def owner_required? user_namespace? end diff --git a/app/models/user.rb b/app/models/user.rb index 0916a89e4d2..9b5583b0e0a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -896,16 +896,6 @@ class User < ApplicationRecord end end - def security_policy_bot - email_pattern = "security-policy-bot%s@#{Settings.gitlab.host}" - - unique_internal(where(user_type: :security_policy_bot), 'security-policy-bot', email_pattern) do |u| - u.bio = 'System bot that creates pipelines for security orchestration policies' - u.name = 'GitLab Security Policy Bot' - u.avatar = bot_avatar(image: 'security-bot.png') - end - end - def admin_bot email_pattern = "admin-bot%s@#{Settings.gitlab.host}" |