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>2021-08-20 09:11:03 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-20 09:11:03 +0300
commit0c51dc19cb6b2a6d9919b129bc6231e3fc1f0bb2 (patch)
tree77ea819381f0b98a25b5b3f457b5762dfca81e3f /app/models
parenta7c6b8d26986b253c5fbe1db1e16ef8d0223093f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r--app/models/diff_note.rb28
-rw-r--r--app/models/note.rb3
-rw-r--r--app/models/shard.rb6
3 files changed, 19 insertions, 18 deletions
diff --git a/app/models/diff_note.rb b/app/models/diff_note.rb
index c8a0773cc5b..6ebac6384bc 100644
--- a/app/models/diff_note.rb
+++ b/app/models/diff_note.rb
@@ -22,7 +22,7 @@ class DiffNote < Note
validate :verify_supported, unless: :importing?
before_validation :set_line_code, if: :on_text?, unless: :importing?
- after_save :keep_around_commits, unless: :importing?
+ after_save :keep_around_commits, unless: -> { importing? || skip_keep_around_commits }
NoteDiffFileCreationError = Class.new(StandardError)
@@ -115,6 +115,20 @@ class DiffNote < Note
position&.multiline?
end
+ def shas
+ [
+ self.original_position.base_sha,
+ self.original_position.start_sha,
+ self.original_position.head_sha
+ ].tap do |a|
+ if self.position != self.original_position
+ a << self.position.base_sha
+ a << self.position.start_sha
+ a << self.position.head_sha
+ end
+ end
+ end
+
private
def enqueue_diff_file_creation_job
@@ -173,18 +187,6 @@ class DiffNote < Note
end
def keep_around_commits
- shas = [
- self.original_position.base_sha,
- self.original_position.start_sha,
- self.original_position.head_sha
- ]
-
- if self.position != self.original_position
- shas << self.position.base_sha
- shas << self.position.start_sha
- shas << self.position.head_sha
- end
-
repository.keep_around(*shas)
end
diff --git a/app/models/note.rb b/app/models/note.rb
index 34ffd7c91af..58a00fe6fa1 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -48,6 +48,9 @@ class Note < ApplicationRecord
# Attribute used to store the attributes that have been changed by quick actions.
attr_accessor :commands_changes
+ # Attribute used to determine whether keep_around_commits will be skipped for diff notes.
+ attr_accessor :skip_keep_around_commits
+
default_value_for :system, false
attr_mentionable :note, pipeline: :note
diff --git a/app/models/shard.rb b/app/models/shard.rb
index 335a279c6aa..9f0039d8bf9 100644
--- a/app/models/shard.rb
+++ b/app/models/shard.rb
@@ -18,10 +18,6 @@ class Shard < ApplicationRecord
end
def self.by_name(name)
- transaction(requires_new: true) do
- find_or_create_by(name: name)
- end
- rescue ActiveRecord::RecordNotUnique
- retry
+ safe_find_or_create_by(name: name)
end
end