summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-04 14:17:05 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-04 14:17:05 +0000
commit2b171e66adf713653c04005e08c02dd823622bdb (patch)
tree977965c0f9e4c93fa66c1f02b876391df115ac97 /app
parentbab5bdce96a258068d69c4b2811f036f151ed60b (diff)
downloadgitlab-ce-2b171e66adf713653c04005e08c02dd823622bdb.tar.gz
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'app')
-rw-r--r--app/models/snippet_repository.rb23
-rw-r--r--app/services/ci/stop_environments_service.rb2
-rw-r--r--app/services/snippets/update_service.rb6
-rw-r--r--app/workers/incident_management/process_alert_worker.rb3
4 files changed, 28 insertions, 6 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
diff --git a/app/services/ci/stop_environments_service.rb b/app/services/ci/stop_environments_service.rb
index 14ef744ada1..b6c5b398cb1 100644
--- a/app/services/ci/stop_environments_service.rb
+++ b/app/services/ci/stop_environments_service.rb
@@ -28,7 +28,7 @@ module Ci
stop_actions.each do |stop_action|
stop_action.play(stop_action.user)
rescue => e
- Gitlab::ErrorTracking.track_error(e, deployable_id: stop_action.id)
+ Gitlab::ErrorTracking.track_exception(e, deployable_id: stop_action.id)
end
end
diff --git a/app/services/snippets/update_service.rb b/app/services/snippets/update_service.rb
index 2dc9266dbd0..250120c1c19 100644
--- a/app/services/snippets/update_service.rb
+++ b/app/services/snippets/update_service.rb
@@ -85,8 +85,10 @@ module Snippets
end
def snippet_files(snippet)
- [{ previous_path: snippet.file_name_on_repo,
- file_path: params[:file_name],
+ file_name_on_repo = snippet.file_name_on_repo
+
+ [{ previous_path: file_name_on_repo,
+ file_path: params[:file_name] || file_name_on_repo,
content: params[:content] }]
end
diff --git a/app/workers/incident_management/process_alert_worker.rb b/app/workers/incident_management/process_alert_worker.rb
index 2ce9fe359b5..0af34fa35d5 100644
--- a/app/workers/incident_management/process_alert_worker.rb
+++ b/app/workers/incident_management/process_alert_worker.rb
@@ -12,7 +12,7 @@ module IncidentManagement
return unless project
new_issue = create_issue(project, alert_payload)
- return unless am_alert_id && new_issue.persisted?
+ return unless am_alert_id && new_issue&.persisted?
link_issue_with_alert(am_alert_id, new_issue.id)
end
@@ -27,6 +27,7 @@ module IncidentManagement
IncidentManagement::CreateIssueService
.new(project, alert_payload)
.execute
+ .dig(:issue)
end
def link_issue_with_alert(alert_id, issue_id)