blob: d4d117f899c0e0de015b1f9e8df65bff2b251f88 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# frozen_string_literal: true
module BlobViewer
class GoMod < DependencyManager
include ServerSide
include Gitlab::Utils::StrongMemoize
MODULE_REGEX = %r{
\A (?# beginning of file)
module\s+ (?# module directive)
(?<name>.*?) (?# module name)
\s*(?://.*)? (?# comment)
(?:\n|\z) (?# newline or end of file)
}x.freeze
self.file_types = %i(go_mod go_sum)
def manager_name
'Go Modules'
end
def manager_url
'https://golang.org/ref/mod'
end
def package_type
'go'
end
def package_name
strong_memoize(:package_name) do
next if blob.name != 'go.mod'
next unless match = MODULE_REGEX.match(blob.data)
match[:name]
end
end
def package_url
Gitlab::Golang.package_url(package_name)
end
end
end
|