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
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-07 15:06:18 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-07 15:06:18 +0300
commit185f428fa5e6123ffa0f29e307523da138e7b028 (patch)
tree1d5bb1d4700c0953aed2ad0e5d3515cc7935e550 /lib
parentab2382923e7a864a3fa27fdf8eeb9b21893b9147 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/analytics/cycle_analytics/default_stages.rb4
-rw-r--r--lib/gitlab/email/receiver.rb21
-rw-r--r--lib/gitlab/import_export/fast_hash_serializer.rb6
-rw-r--r--lib/gitlab/metrics/exporter/base_exporter.rb3
-rw-r--r--lib/tasks/gitlab/cleanup.rake63
5 files changed, 23 insertions, 74 deletions
diff --git a/lib/gitlab/analytics/cycle_analytics/default_stages.rb b/lib/gitlab/analytics/cycle_analytics/default_stages.rb
index 286c393005f..711645800fb 100644
--- a/lib/gitlab/analytics/cycle_analytics/default_stages.rb
+++ b/lib/gitlab/analytics/cycle_analytics/default_stages.rb
@@ -23,6 +23,10 @@ module Gitlab
]
end
+ def self.names
+ all.map { |stage| stage[:name] }
+ end
+
def self.params_for_issue_stage
{
name: 'issue',
diff --git a/lib/gitlab/email/receiver.rb b/lib/gitlab/email/receiver.rb
index 7da8b385266..847260b2e0f 100644
--- a/lib/gitlab/email/receiver.rb
+++ b/lib/gitlab/email/receiver.rb
@@ -32,7 +32,7 @@ module Gitlab
mail = build_mail
- ignore_auto_submitted!(mail)
+ ignore_auto_reply!(mail)
mail_key = extract_mail_key(mail)
handler = Handler.for(mail, mail_key)
@@ -96,14 +96,25 @@ module Gitlab
end
end
- def ignore_auto_submitted!(mail)
+ def ignore_auto_reply!(mail)
+ if auto_submitted?(mail) || auto_replied?(mail)
+ raise AutoGeneratedEmailError
+ end
+ end
+
+ def auto_submitted?(mail)
# Mail::Header#[] is case-insensitive
auto_submitted = mail.header['Auto-Submitted']&.value
# Mail::Field#value would strip leading and trailing whitespace
- raise AutoGeneratedEmailError if
- # See also https://tools.ietf.org/html/rfc3834
- auto_submitted && auto_submitted != 'no'
+ # See also https://tools.ietf.org/html/rfc3834
+ auto_submitted && auto_submitted != 'no'
+ end
+
+ def auto_replied?(mail)
+ autoreply = mail.header['X-Autoreply']&.value
+
+ autoreply && autoreply == 'yes'
end
end
end
diff --git a/lib/gitlab/import_export/fast_hash_serializer.rb b/lib/gitlab/import_export/fast_hash_serializer.rb
index e2d5c5ae055..5a067b5c9f3 100644
--- a/lib/gitlab/import_export/fast_hash_serializer.rb
+++ b/lib/gitlab/import_export/fast_hash_serializer.rb
@@ -135,10 +135,7 @@ module Gitlab
data = []
- # rubocop:disable Cop/InBatches
- # If we put `rubocop:disable` inline after `do |batch|`,
- # `Cop/LineBreakAroundConditionalBlock` will fail
- record.in_batches(of: @batch_size) do |batch|
+ record.in_batches(of: @batch_size) do |batch| # rubocop:disable Cop/InBatches
if Feature.enabled?(:export_fast_serialize_with_raw_json, default_enabled: true)
data.append(JSONBatchRelation.new(batch, options, preloads[key]).tap(&:raw_json))
else
@@ -146,7 +143,6 @@ module Gitlab
data += batch.as_json(options)
end
end
- # rubocop:enable Cop/InBatches
data
end
diff --git a/lib/gitlab/metrics/exporter/base_exporter.rb b/lib/gitlab/metrics/exporter/base_exporter.rb
index 108d1330b47..de7870dfb8c 100644
--- a/lib/gitlab/metrics/exporter/base_exporter.rb
+++ b/lib/gitlab/metrics/exporter/base_exporter.rb
@@ -36,10 +36,11 @@ module Gitlab
end
def stop_working
- if server # rubocop:disable Cop/LineBreakAroundConditionalBlock
+ if server
server.shutdown
server.listeners.each(&:close)
end
+
@server = nil
end
diff --git a/lib/tasks/gitlab/cleanup.rake b/lib/tasks/gitlab/cleanup.rake
index 4d854cd178d..0a0ee7b4bfa 100644
--- a/lib/tasks/gitlab/cleanup.rake
+++ b/lib/tasks/gitlab/cleanup.rake
@@ -3,69 +3,6 @@ require 'set'
namespace :gitlab do
namespace :cleanup do
- desc "GitLab | Cleanup | Clean namespaces"
- task dirs: :gitlab_environment do
- namespaces = Set.new(Namespace.pluck(:path))
- namespaces << Storage::HashedProject::REPOSITORY_PATH_PREFIX
-
- Gitaly::Server.all.each do |server|
- all_dirs = Gitlab::GitalyClient::StorageService
- .new(server.storage)
- .list_directories(depth: 0)
- .reject { |dir| dir.ends_with?('.git') || namespaces.include?(File.basename(dir)) }
-
- puts "Looking for directories to remove... "
- all_dirs.each do |dir_path|
- if remove?
- begin
- Gitlab::GitalyClient::NamespaceService.new(server.storage)
- .remove(dir_path)
-
- puts "Removed...#{dir_path}"
- rescue StandardError => e
- puts "Cannot remove #{dir_path}: #{e.message}".color(:red)
- end
- else
- puts "Can be removed: #{dir_path}".color(:red)
- end
- end
- end
-
- unless remove?
- puts "To cleanup this directories run this command with REMOVE=true".color(:yellow)
- end
- end
-
- desc "GitLab | Cleanup | Clean repositories"
- task repos: :gitlab_environment do
- move_suffix = "+orphaned+#{Time.now.to_i}"
-
- Gitaly::Server.all.each do |server|
- Gitlab::GitalyClient::StorageService
- .new(server.storage)
- .list_directories
- .each do |path|
- repo_with_namespace = path.chomp('.git').chomp('.wiki')
-
- # TODO ignoring hashed repositories for now. But revisit to fully support
- # possible orphaned hashed repos
- next if repo_with_namespace.start_with?(Storage::HashedProject::REPOSITORY_PATH_PREFIX)
- next if Project.find_by_full_path(repo_with_namespace)
-
- new_path = path + move_suffix
- puts path.inspect + ' -> ' + new_path.inspect
-
- begin
- Gitlab::GitalyClient::NamespaceService
- .new(server.storage)
- .rename(path, new_path)
- rescue StandardError => e
- puts "Error occurred while moving the repository: #{e.message}".color(:red)
- end
- end
- end
- end
-
desc "GitLab | Cleanup | Block users that have been removed in LDAP"
task block_removed_ldap_users: :gitlab_environment do
warn_user_is_not_gitlab