2020-04-02 05:08:14 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
class CodeNavigationPath
|
|
|
|
include Gitlab::Utils::StrongMemoize
|
|
|
|
include Gitlab::Routing
|
|
|
|
|
2020-07-07 11:08:49 -04:00
|
|
|
LATEST_COMMITS_LIMIT = 2
|
2020-04-02 05:08:14 -04:00
|
|
|
|
|
|
|
def initialize(project, commit_sha)
|
|
|
|
@project = project
|
|
|
|
@commit_sha = commit_sha
|
|
|
|
end
|
|
|
|
|
|
|
|
def full_json_path_for(path)
|
|
|
|
return unless build
|
|
|
|
|
2020-05-15 17:08:21 -04:00
|
|
|
raw_project_job_artifacts_path(project, build, path: "lsif/#{path}.json", file_type: :lsif)
|
2020-04-02 05:08:14 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
attr_reader :project, :commit_sha
|
|
|
|
|
|
|
|
def build
|
|
|
|
strong_memoize(:build) do
|
2020-05-13 08:07:54 -04:00
|
|
|
latest_commits_shas =
|
|
|
|
project.repository.commits(commit_sha, limit: LATEST_COMMITS_LIMIT).map(&:sha)
|
|
|
|
|
2020-07-16 14:09:35 -04:00
|
|
|
pipeline = @project.ci_pipelines.for_sha(latest_commits_shas).last
|
|
|
|
|
|
|
|
next unless pipeline
|
|
|
|
|
|
|
|
artifact = pipeline.job_artifacts.with_file_types(['lsif']).last
|
2020-04-02 05:08:14 -04:00
|
|
|
|
|
|
|
artifact&.job
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|