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:
authorDouwe Maan <douwe@selenight.nl>2017-05-16 23:30:29 +0300
committerDouwe Maan <douwe@selenight.nl>2017-05-23 23:35:59 +0300
commitc734f2f0dd5ea5220b60a9dde9b3abef4f33fd93 (patch)
tree725129b7d44d8eacafa6d640d68f331ccd523712 /lib
parent640440c9d8e1dea94067825e79734eb0f9774acf (diff)
Autolink package names in requirements.txt
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/dependency_linker.rb1
-rw-r--r--lib/gitlab/dependency_linker/requirements_txt_linker.rb17
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/gitlab/dependency_linker.rb b/lib/gitlab/dependency_linker.rb
index 9ff355a9085..3192bf6f667 100644
--- a/lib/gitlab/dependency_linker.rb
+++ b/lib/gitlab/dependency_linker.rb
@@ -10,6 +10,7 @@ module Gitlab
PodspecJsonLinker,
CartfileLinker,
GodepsJsonLinker,
+ RequirementsTxtLinker
].freeze
def self.linker(blob_name)
diff --git a/lib/gitlab/dependency_linker/requirements_txt_linker.rb b/lib/gitlab/dependency_linker/requirements_txt_linker.rb
new file mode 100644
index 00000000000..2e197e5cd94
--- /dev/null
+++ b/lib/gitlab/dependency_linker/requirements_txt_linker.rb
@@ -0,0 +1,17 @@
+module Gitlab
+ module DependencyLinker
+ class RequirementsTxtLinker < BaseLinker
+ self.file_type = :requirements_txt
+
+ private
+
+ def link_dependencies
+ link_regex(/^(?<name>(?![a-z+]+:)[^#.-][^ ><=;\[]+)/) do |name|
+ "https://pypi.python.org/pypi/#{name}"
+ end
+
+ link_regex(%r{^(?<name>https?://[^ ]+)}, &:itself)
+ end
+ end
+ end
+end