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:
Diffstat (limited to 'lib/bulk_imports/common/pipelines/wiki_pipeline.rb')
-rw-r--r--lib/bulk_imports/common/pipelines/wiki_pipeline.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/bulk_imports/common/pipelines/wiki_pipeline.rb b/lib/bulk_imports/common/pipelines/wiki_pipeline.rb
new file mode 100644
index 00000000000..ccab0b979b2
--- /dev/null
+++ b/lib/bulk_imports/common/pipelines/wiki_pipeline.rb
@@ -0,0 +1,42 @@
+# frozen_string_literal: true
+
+module BulkImports
+ module Common
+ module Pipelines
+ class WikiPipeline
+ include Pipeline
+
+ def extract(*)
+ BulkImports::Pipeline::ExtractedData.new(data: { url: url_from_parent_path(context.entity.source_full_path) })
+ end
+
+ def transform(_, data)
+ data&.slice(:url)
+ end
+
+ def load(context, data)
+ return unless context.portable.wiki
+
+ url = data[:url].sub("://", "://oauth2:#{context.configuration.access_token}@")
+
+ Gitlab::UrlBlocker.validate!(url, allow_local_network: allow_local_requests?, allow_localhost: allow_local_requests?)
+
+ context.portable.wiki.ensure_repository
+ context.portable.wiki.repository.fetch_as_mirror(url)
+ end
+
+ private
+
+ def url_from_parent_path(parent_path)
+ wiki_path = parent_path + ".wiki.git"
+ root = context.configuration.url
+ Gitlab::Utils.append_path(root, wiki_path)
+ end
+
+ def allow_local_requests?
+ Gitlab::CurrentSettings.allow_local_requests_from_web_hooks_and_services?
+ end
+ end
+ end
+ end
+end