diff options
Diffstat (limited to 'lib/gitlab/code_navigation_path.rb')
-rw-r--r-- | lib/gitlab/code_navigation_path.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/gitlab/code_navigation_path.rb b/lib/gitlab/code_navigation_path.rb index 8dd2e9cb1bb..57aeb6c4fb2 100644 --- a/lib/gitlab/code_navigation_path.rb +++ b/lib/gitlab/code_navigation_path.rb @@ -5,7 +5,7 @@ module Gitlab include Gitlab::Utils::StrongMemoize include Gitlab::Routing - CODE_NAVIGATION_JOB_NAME = 'code_navigation' + LATEST_COMMITS_LIMIT = 10 def initialize(project, commit_sha) @project = project @@ -16,7 +16,7 @@ module Gitlab return if Feature.disabled?(:code_navigation, project) return unless build - raw_project_job_artifacts_path(project, build, path: "lsif/#{path}.json") + raw_project_job_artifacts_path(project, build, path: "lsif/#{path}.json", file_type: :lsif) end private @@ -25,10 +25,14 @@ module Gitlab def build strong_memoize(:build) do - artifact = ::Ci::JobArtifact - .for_sha(commit_sha, project.id) - .for_job_name(CODE_NAVIGATION_JOB_NAME) - .last + latest_commits_shas = + project.repository.commits(commit_sha, limit: LATEST_COMMITS_LIMIT).map(&:sha) + + artifact = + ::Ci::JobArtifact + .with_file_types(['lsif']) + .for_sha(latest_commits_shas, project.id) + .last artifact&.job end |