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-06-04 17:17:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-04 17:17:05 +0300
commit2b171e66adf713653c04005e08c02dd823622bdb (patch)
tree977965c0f9e4c93fa66c1f02b876391df115ac97 /app/models
parentbab5bdce96a258068d69c4b2811f036f151ed60b (diff)
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'app/models')
-rw-r--r--app/models/snippet_repository.rb23
1 files changed, 21 insertions, 2 deletions
diff --git a/app/models/snippet_repository.rb b/app/models/snippet_repository.rb
index 2276851b7a1..8151308125a 100644
--- a/app/models/snippet_repository.rb
+++ b/app/models/snippet_repository.rb
@@ -53,10 +53,21 @@ class SnippetRepository < ApplicationRecord
def transform_file_entries(files)
next_index = get_last_empty_file_index + 1
- files.each do |file_entry|
+ files.map do |file_entry|
file_entry[:file_path] = file_path_for(file_entry, next_index) { next_index += 1 }
file_entry[:action] = infer_action(file_entry) unless file_entry[:action]
- end
+ file_entry[:action] = file_entry[:action].to_sym
+
+ if only_rename_action?(file_entry)
+ file_entry[:infer_content] = true
+ elsif empty_update_action?(file_entry)
+ # There is no need to perform a repository operation
+ # When the update action has no content
+ file_entry = nil
+ end
+
+ file_entry
+ end.compact
end
def file_path_for(file_entry, next_index)
@@ -111,4 +122,12 @@ class SnippetRepository < ApplicationRecord
err.is_a?(ArgumentError) &&
err.message.downcase.match?(/failed to parse signature/)
end
+
+ def only_rename_action?(action)
+ action[:action] == :move && action[:content].nil?
+ end
+
+ def empty_update_action?(action)
+ action[:action] == :update && action[:content].nil?
+ end
end