2018-11-05 23:45:35 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-16 16:30:18 -04:00
|
|
|
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
|
2020-01-27 07:08:35 -05:00
|
|
|
when %r{\A(?<repo>github\.com/#{REPO_REGEX})/(?<path>.+)\z}
|
|
|
|
"https://#{$~[:repo]}/tree/master/#{$~[:path]}"
|
2017-05-16 16:30:18 -04:00
|
|
|
when %r{\A(?<repo>gitlab\.com/#{NESTED_REPO_REGEX})\.git/(?<path>.+)\z},
|
2020-01-27 07:08:35 -05:00
|
|
|
%r{\A(?<repo>gitlab\.com/#{REPO_REGEX})/(?<path>.+)\z}
|
2017-05-16 16:30:18 -04:00
|
|
|
|
2020-01-27 07:08:35 -05:00
|
|
|
"https://#{$~[:repo]}/-/tree/master/#{$~[:path]}"
|
2017-05-16 16:30:18 -04:00
|
|
|
when /\Agolang\.org/
|
|
|
|
"https://godoc.org/#{path}"
|
|
|
|
else
|
|
|
|
"https://#{path}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|