diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-05-16 15:30:18 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-05-23 15:35:51 -0500 |
commit | 640440c9d8e1dea94067825e79734eb0f9774acf (patch) | |
tree | 9f54c0e0eae457aefef56b4d0de490bb79fa42dc /lib/gitlab/dependency_linker | |
parent | e780259a650ea476be0617c435798b85a252605a (diff) | |
download | gitlab-ce-640440c9d8e1dea94067825e79734eb0f9774acf.tar.gz |
Autolink package names in Godeps.json
Diffstat (limited to 'lib/gitlab/dependency_linker')
-rw-r--r-- | lib/gitlab/dependency_linker/godeps_json_linker.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/gitlab/dependency_linker/godeps_json_linker.rb b/lib/gitlab/dependency_linker/godeps_json_linker.rb new file mode 100644 index 00000000000..fe091baee6d --- /dev/null +++ b/lib/gitlab/dependency_linker/godeps_json_linker.rb @@ -0,0 +1,26 @@ +module Gitlab + module DependencyLinker + class GodepsJsonLinker < JsonLinker + NESTED_REPO_REGEX = %r{([^/]+/)+[^/]+?}.freeze + + self.file_type = :godeps_json + + private + + def link_dependencies + link_json('ImportPath') do |path| + case path + when %r{\A(?<repo>gitlab\.com/#{NESTED_REPO_REGEX})\.git/(?<path>.+)\z}, + %r{\A(?<repo>git(lab|hub)\.com/#{REPO_REGEX})/(?<path>.+)\z} + + "https://#{$~[:repo]}/tree/master/#{$~[:path]}" + when /\Agolang\.org/ + "https://godoc.org/#{path}" + else + "https://#{path}" + end + end + end + end + end +end |