2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
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
|
2022-08-27 11:52:29 +05:30
|
|
|
when %r{\A(?<repo>github\.com/#{REPO_REGEX})/(?<path>.+)\z}o
|
2020-03-13 15:44:24 +05:30
|
|
|
"https://#{$~[:repo]}/tree/master/#{$~[:path]}"
|
2022-08-27 11:52:29 +05:30
|
|
|
when %r{\A(?<repo>gitlab\.com/#{NESTED_REPO_REGEX})\.git/(?<path>.+)\z}o,
|
|
|
|
%r{\A(?<repo>gitlab\.com/#{REPO_REGEX})/(?<path>.+)\z}o
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
"https://#{$~[:repo]}/-/tree/master/#{$~[:path]}"
|
2017-09-10 17:25:29 +05:30
|
|
|
when /\Agolang\.org/
|
|
|
|
"https://godoc.org/#{path}"
|
|
|
|
else
|
|
|
|
"https://#{path}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|