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:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-05-12 15:08:30 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-12 15:08:30 +0300
commitcb3b9f9243555b0c26145e2992a9f01f7fa47bf5 (patch)
tree5fea3438f0c21330e2fba8c958cbc505810ab990 /app/models
parent71d34aac9a0fae0507c265929767422391816b01 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/secure_file.rb7
-rw-r--r--app/models/event.rb4
-rw-r--r--app/models/merge_request.rb24
-rw-r--r--app/models/wiki.rb40
-rw-r--r--app/models/work_items/type.rb4
5 files changed, 28 insertions, 51 deletions
diff --git a/app/models/ci/secure_file.rb b/app/models/ci/secure_file.rb
index 6a26a5341aa..9c82e106d6e 100644
--- a/app/models/ci/secure_file.rb
+++ b/app/models/ci/secure_file.rb
@@ -3,8 +3,11 @@
module Ci
class SecureFile < Ci::ApplicationRecord
include FileStoreMounter
+ include IgnorableColumns
include Limitable
+ ignore_column :permissions, remove_with: '15.2', remove_after: '2022-06-22'
+
FILE_SIZE_LIMIT = 5.megabytes.freeze
CHECKSUM_ALGORITHM = 'sha256'
@@ -14,14 +17,12 @@ module Ci
belongs_to :project, optional: false
validates :file, presence: true, file_size: { maximum: FILE_SIZE_LIMIT }
- validates :checksum, :file_store, :name, :permissions, :project_id, presence: true
+ validates :checksum, :file_store, :name, :project_id, presence: true
validates :name, uniqueness: { scope: :project }
after_initialize :generate_key_data
before_validation :assign_checksum
- enum permissions: { read_only: 0, read_write: 1, execute: 2 }
-
default_value_for(:file_store) { Ci::SecureFileUploader.default_store }
mount_file_store_uploader Ci::SecureFileUploader
diff --git a/app/models/event.rb b/app/models/event.rb
index e9a98c06b59..8ae2f61f36d 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -369,6 +369,10 @@ class Event < ApplicationRecord
Event._to_partial_path
end
+ def has_no_project_and_group?
+ project_id.nil? && group_id.nil?
+ end
+
protected
def capability
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 5adc5a656c8..39b5949ea7a 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -1438,30 +1438,8 @@ class MergeRequest < ApplicationRecord
actual_head_pipeline.success?
end
- ##
- # This method is for looking for active environments which created via pipelines for merge requests.
- # Since deployments run on a merge request ref (e.g. `refs/merge-requests/:iid/head`),
- # we cannot look up environments with source branch name.
- def legacy_environments
- return Environment.none unless actual_head_pipeline&.merge_request?
-
- build_for_actual_head_pipeline = Ci::Build.latest.where(pipeline: actual_head_pipeline)
-
- environments = build_for_actual_head_pipeline.joins(:metadata)
- .where.not('ci_builds_metadata.expanded_environment_name' => nil)
- .distinct('ci_builds_metadata.expanded_environment_name')
- .limit(100)
- .pluck(:expanded_environment_name)
-
- Environment.where(project: project, name: environments)
- end
-
def environments_in_head_pipeline(deployment_status: nil)
- if ::Feature.enabled?(:fix_related_environments_for_merge_requests, target_project)
- actual_head_pipeline&.environments_in_self_and_descendants(deployment_status: deployment_status) || Environment.none
- else
- legacy_environments
- end
+ actual_head_pipeline&.environments_in_self_and_descendants(deployment_status: deployment_status) || Environment.none
end
def fetch_ref!
diff --git a/app/models/wiki.rb b/app/models/wiki.rb
index ca1266e50f4..32d70fcd3b7 100644
--- a/app/models/wiki.rb
+++ b/app/models/wiki.rb
@@ -261,36 +261,26 @@ class Wiki
end
def update_page(page, content:, title: nil, format: :markdown, message: nil)
- if Feature.enabled?(:gitaly_replace_wiki_update_page, container, type: :undefined)
- with_valid_format(format) do |default_extension|
- title = title.presence || Pathname(page.path).sub_ext('').to_s
+ with_valid_format(format) do |default_extension|
+ title = title.presence || Pathname(page.path).sub_ext('').to_s
- # If the format is the same we keep the former extension. This check is for formats
- # that can have more than one extension like Markdown (.md, .markdown)
- # If we don't do this we will override the existing extension.
- extension = page.format != format.to_sym ? default_extension : File.extname(page.path).downcase[1..]
+ # If the format is the same we keep the former extension. This check is for formats
+ # that can have more than one extension like Markdown (.md, .markdown)
+ # If we don't do this we will override the existing extension.
+ extension = page.format != format.to_sym ? default_extension : File.extname(page.path).downcase[1..]
- capture_git_error(:updated) do
- repository.update_file(
- user,
- sluggified_full_path(title, extension),
- content,
- previous_path: page.path,
- **multi_commit_options(:updated, message, title))
+ capture_git_error(:updated) do
+ repository.update_file(
+ user,
+ sluggified_full_path(title, extension),
+ content,
+ previous_path: page.path,
+ **multi_commit_options(:updated, message, title))
- after_wiki_activity
+ after_wiki_activity
- true
- end
+ true
end
- else
- commit = commit_details(:updated, message, page.title)
-
- wiki.update_page(page.path, title || page.name, format.to_sym, content, commit)
-
- after_wiki_activity
-
- true
end
end
diff --git a/app/models/work_items/type.rb b/app/models/work_items/type.rb
index e2d38dc9903..0d390fa131d 100644
--- a/app/models/work_items/type.rb
+++ b/app/models/work_items/type.rb
@@ -41,6 +41,10 @@ module WorkItems
scope :by_type, ->(base_type) { where(base_type: base_type) }
def self.default_by_type(type)
+ found_type = find_by(namespace_id: nil, base_type: type)
+ return found_type if found_type
+
+ Gitlab::DatabaseImporters::WorkItems::BaseTypeImporter.upsert_types
find_by(namespace_id: nil, base_type: type)
end