blob: ed8bd5599d9fcf5576f2d2663a53bf1e569a4756 (
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
|
# frozen_string_literal: true
module Packages
module Go
class ModuleFinder
include Gitlab::Golang
attr_reader :project, :module_name
def initialize(project, module_name)
module_name = Pathname.new(module_name).cleanpath.to_s
@project = project
@module_name = module_name
end
def execute
return if @module_name.blank? || !@module_name.start_with?(local_module_prefix)
module_path = @module_name[local_module_prefix.length..].split('/')
project_path = project.full_path.split('/')
module_project_path = module_path.shift(project_path.length)
return unless module_project_path == project_path
Packages::Go::Module.new(@project, @module_name, module_path.join('/'))
end
end
end
end
|