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>2020-04-14 18:09:44 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-14 18:09:44 +0300
commit874ead9c3a50de4c4ca4551eaf5b7eb976d26b50 (patch)
tree637ee9f2da5e251bc08ebf3e972209d51966bf7c /app/models
parent2e4c4055181eec9186458dd5dd3219c937032ec7 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r--app/models/application_setting_implementation.rb1
-rw-r--r--app/models/ci/job_artifact.rb15
-rw-r--r--app/models/diff_note_position.rb36
-rw-r--r--app/models/lfs_object.rb13
4 files changed, 63 insertions, 2 deletions
diff --git a/app/models/application_setting_implementation.rb b/app/models/application_setting_implementation.rb
index 920ad3286d1..c96f086684f 100644
--- a/app/models/application_setting_implementation.rb
+++ b/app/models/application_setting_implementation.rb
@@ -79,6 +79,7 @@ module ApplicationSettingImplementation
housekeeping_gc_period: 200,
housekeeping_incremental_repack_period: 10,
import_sources: Settings.gitlab['import_sources'],
+ issues_create_limit: 300,
local_markdown_version: 0,
max_artifacts_size: Settings.artifacts['max_size'],
max_attachment_size: Settings.gitlab['max_attachment_size'],
diff --git a/app/models/ci/job_artifact.rb b/app/models/ci/job_artifact.rb
index ef0701b3874..c4ac10814a9 100644
--- a/app/models/ci/job_artifact.rb
+++ b/app/models/ci/job_artifact.rb
@@ -73,12 +73,14 @@ module Ci
validates :file_format, presence: true, unless: :trace?, on: :create
validate :valid_file_format?, unless: :trace?, on: :create
- before_save :set_size, if: :file_changed?
- update_project_statistics project_statistics_name: :build_artifacts_size
+ before_save :set_size, if: :file_changed?
+ before_save :set_file_store, if: ->(job_artifact) { job_artifact.file_store.nil? }
after_save :update_file_store, if: :saved_change_to_file?
+ update_project_statistics project_statistics_name: :build_artifacts_size
+
scope :with_files_stored_locally, -> { where(file_store: [nil, ::JobArtifactUploader::Store::LOCAL]) }
scope :with_files_stored_remotely, -> { where(file_store: ::JobArtifactUploader::Store::REMOTE) }
scope :for_sha, ->(sha, project_id) { joins(job: :pipeline).where(ci_pipelines: { sha: sha, project_id: project_id }) }
@@ -226,6 +228,15 @@ module Ci
self.size = file.size
end
+ def set_file_store
+ self.file_store =
+ if JobArtifactUploader.object_store_enabled? && JobArtifactUploader.direct_upload_enabled?
+ JobArtifactUploader::Store::REMOTE
+ else
+ file.object_store
+ end
+ end
+
def project_destroyed?
# Use job.project to avoid extra DB query for project
job.project.pending_delete?
diff --git a/app/models/diff_note_position.rb b/app/models/diff_note_position.rb
new file mode 100644
index 00000000000..78e4fbc49eb
--- /dev/null
+++ b/app/models/diff_note_position.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+class DiffNotePosition < ApplicationRecord
+ belongs_to :note
+
+ enum diff_content_type: {
+ text: 0,
+ image: 1
+ }
+
+ enum diff_type: {
+ head: 0
+ }
+
+ def position
+ Gitlab::Diff::Position.new(
+ old_path: old_path,
+ new_path: new_path,
+ old_line: old_line,
+ new_line: new_line,
+ position_type: diff_content_type,
+ diff_refs: Gitlab::Diff::DiffRefs.new(
+ base_sha: base_sha,
+ start_sha: start_sha,
+ head_sha: head_sha
+ )
+ )
+ end
+
+ def position=(position)
+ position_attrs = position.to_h
+ position_attrs[:diff_content_type] = position_attrs.delete(:position_type)
+
+ assign_attributes(position_attrs)
+ end
+end
diff --git a/app/models/lfs_object.rb b/app/models/lfs_object.rb
index 6a86aebae39..c5233deaa96 100644
--- a/app/models/lfs_object.rb
+++ b/app/models/lfs_object.rb
@@ -17,6 +17,8 @@ class LfsObject < ApplicationRecord
mount_uploader :file, LfsObjectUploader
+ before_save :set_file_store, if: ->(lfs_object) { lfs_object.file_store.nil? }
+
after_save :update_file_store, if: :saved_change_to_file?
def self.not_linked_to_project(project)
@@ -55,6 +57,17 @@ class LfsObject < ApplicationRecord
def self.calculate_oid(path)
self.hexdigest(path)
end
+
+ private
+
+ def set_file_store
+ self.file_store =
+ if LfsObjectUploader.object_store_enabled? && LfsObjectUploader.direct_upload_enabled?
+ LfsObjectUploader::Store::REMOTE
+ else
+ file.object_store
+ end
+ end
end
LfsObject.prepend_if_ee('EE::LfsObject')