blob: 909d0536b5f2437672630040ef0584ad3ef9c9d5 (
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
|
# frozen_string_literal: true
module Gitlab
class CodeNavigationPath
include Gitlab::Utils::StrongMemoize
include Gitlab::Routing
LATEST_COMMITS_LIMIT = 2
def initialize(project, commit_sha)
@project = project
@commit_sha = commit_sha
end
def full_json_path_for(path)
return unless Feature.enabled?(:code_navigation, project, default_enabled: true)
return unless build
raw_project_job_artifacts_path(project, build, path: "lsif/#{path}.json", file_type: :lsif)
end
private
attr_reader :project, :commit_sha
def build
strong_memoize(:build) do
latest_commits_shas =
project.repository.commits(commit_sha, limit: LATEST_COMMITS_LIMIT).map(&:sha)
pipeline = @project.ci_pipelines.for_sha(latest_commits_shas).last
next unless pipeline
artifact = pipeline.job_artifacts.with_file_types(['lsif']).last
artifact&.job
end
end
end
end
|