Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb71
1 files changed, 31 insertions, 40 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index daa5605c2e0..ec790798806 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -34,6 +34,7 @@ class Project < ApplicationRecord
include FromUnion
include IgnorableColumns
include Integration
+ include Repositories::CanHousekeepRepository
include EachBatch
extend Gitlab::Cache::RequestCache
extend Gitlab::Utils::Override
@@ -146,7 +147,6 @@ class Project < ApplicationRecord
has_many :boards
# Project services
- has_one :alerts_service
has_one :campfire_service
has_one :datadog_service
has_one :discord_service
@@ -200,6 +200,8 @@ class Project < ApplicationRecord
# Packages
has_many :packages, class_name: 'Packages::Package'
has_many :package_files, through: :packages, class_name: 'Packages::PackageFile'
+ # debian_distributions must be destroyed by ruby code in order to properly remove carrierwave uploads
+ has_many :debian_distributions, class_name: 'Packages::Debian::ProjectDistribution', dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_one :import_state, autosave: true, class_name: 'ProjectImportState', inverse_of: :project
has_one :import_export_upload, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
@@ -408,6 +410,9 @@ class Project < ApplicationRecord
delegate :dashboard_timezone, to: :metrics_setting, allow_nil: true, prefix: true
delegate :default_git_depth, :default_git_depth=, to: :ci_cd_settings, prefix: :ci
delegate :forward_deployment_enabled, :forward_deployment_enabled=, :forward_deployment_enabled?, to: :ci_cd_settings, prefix: :ci
+ delegate :keep_latest_artifact, :keep_latest_artifact=, :keep_latest_artifact?, to: :ci_cd_settings, prefix: :ci
+ delegate :restrict_user_defined_variables, :restrict_user_defined_variables=, :restrict_user_defined_variables?,
+ to: :ci_cd_settings
delegate :actual_limits, :actual_plan_name, to: :namespace, allow_nil: true
delegate :allow_merge_on_skipped_pipeline, :allow_merge_on_skipped_pipeline?,
:allow_merge_on_skipped_pipeline=, :has_confluence?, :allow_editing_commit_messages?,
@@ -831,6 +836,10 @@ class Project < ApplicationRecord
webide_pipelines.running_or_pending.for_user(user)
end
+ def latest_pipeline_locked
+ ci_keep_latest_artifact? ? :artifacts_locked : :unlocked
+ end
+
def autoclose_referenced_issues
return true if super.nil?
@@ -1331,19 +1340,11 @@ class Project < ApplicationRecord
end
def external_wiki
- if has_external_wiki.nil?
- cache_has_external_wiki
- end
+ cache_has_external_wiki if has_external_wiki.nil?
- if has_external_wiki
- @external_wiki ||= services.external_wikis.first
- else
- nil
- end
- end
+ return unless has_external_wiki?
- def cache_has_external_wiki
- update_column(:has_external_wiki, services.external_wikis.any?) if Gitlab::Database.read_write?
+ @external_wiki ||= services.external_wikis.first
end
def find_or_initialize_services
@@ -1355,9 +1356,9 @@ class Project < ApplicationRecord
end
def disabled_services
- return ['datadog'] unless Feature.enabled?(:datadog_ci_integration, self)
+ return %w(datadog alerts) unless Feature.enabled?(:datadog_ci_integration, self)
- []
+ %w(alerts)
end
def find_or_initialize_service(name)
@@ -1829,6 +1830,15 @@ class Project < ApplicationRecord
ensure_pages_metadatum.update!(pages_deployment: deployment)
end
+ def set_first_pages_deployment!(deployment)
+ ensure_pages_metadatum
+
+ # where().update_all to perform update in the single transaction with check for null
+ ProjectPagesMetadatum
+ .where(project_id: id, pages_deployment_id: nil)
+ .update_all(pages_deployment_id: deployment.id)
+ end
+
def write_repository_config(gl_full_path: full_path)
# We'd need to keep track of project full path otherwise directory tree
# created with hashed storage enabled cannot be usefully imported using
@@ -1980,6 +1990,7 @@ class Project < ApplicationRecord
.append(key: 'CI_PROJECT_VISIBILITY', value: Gitlab::VisibilityLevel.string_level(visibility_level))
.append(key: 'CI_PROJECT_REPOSITORY_LANGUAGES', value: repository_languages.map(&:name).join(',').downcase)
.append(key: 'CI_DEFAULT_BRANCH', value: default_branch)
+ .append(key: 'CI_PROJECT_CONFIG_PATH', value: ci_config_path_or_default)
end
def predefined_ci_server_variables
@@ -2113,18 +2124,6 @@ class Project < ApplicationRecord
(auto_devops || build_auto_devops)&.predefined_variables
end
- def pushes_since_gc
- Gitlab::Redis::SharedState.with { |redis| redis.get(pushes_since_gc_redis_shared_state_key).to_i }
- end
-
- def increment_pushes_since_gc
- Gitlab::Redis::SharedState.with { |redis| redis.incr(pushes_since_gc_redis_shared_state_key) }
- end
-
- def reset_pushes_since_gc
- Gitlab::Redis::SharedState.with { |redis| redis.del(pushes_since_gc_redis_shared_state_key) }
- end
-
def route_map_for(commit_sha)
@route_maps_by_commit ||= Hash.new do |h, sha|
h[sha] = begin
@@ -2430,10 +2429,6 @@ class Project < ApplicationRecord
protected_branches.limit(limit)
end
- def alerts_service_activated?
- alerts_service&.active?
- end
-
def self_monitoring?
Gitlab::CurrentSettings.self_monitoring_project_id == id
end
@@ -2486,16 +2481,12 @@ class Project < ApplicationRecord
end
def service_desk_custom_address
- return unless service_desk_custom_address_enabled?
+ return unless Gitlab::ServiceDeskEmail.enabled?
key = service_desk_setting&.project_key
return unless key.present?
- ::Gitlab::ServiceDeskEmail.address_for_key("#{full_path_slug}-#{key}")
- end
-
- def service_desk_custom_address_enabled?
- ::Gitlab::ServiceDeskEmail.enabled? && ::Feature.enabled?(:service_desk_custom_address, self, default_enabled: true)
+ Gitlab::ServiceDeskEmail.address_for_key("#{full_path_slug}-#{key}")
end
def root_namespace
@@ -2633,10 +2624,6 @@ class Project < ApplicationRecord
from && self != from
end
- def pushes_since_gc_redis_shared_state_key
- "projects/#{id}/pushes_since_gc"
- end
-
def update_project_statistics
stats = statistics || build_statistics
stats.update(namespace_id: namespace_id)
@@ -2699,6 +2686,10 @@ class Project < ApplicationRecord
objects.each_batch { |relation| out.concat(relation.pluck(:oid)) }
end
end
+
+ def cache_has_external_wiki
+ update_column(:has_external_wiki, services.external_wikis.any?) if Gitlab::Database.read_write?
+ end
end
Project.prepend_if_ee('EE::Project')