summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-02 09:08:14 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-02 09:08:14 +0000
commitade18c9d68d5a2e6c6e28ef7e9d3add3b3491ace (patch)
treecf4154332fc95283f58cccb1383e43b40485d91d /lib
parentba836d98593d68d8d6c22c540e31c8031a786bd8 (diff)
downloadgitlab-ce-ade18c9d68d5a2e6c6e28ef7e9d3add3b3491ace.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/code_navigation_path.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/gitlab/code_navigation_path.rb b/lib/gitlab/code_navigation_path.rb
new file mode 100644
index 00000000000..8dd2e9cb1bb
--- /dev/null
+++ b/lib/gitlab/code_navigation_path.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+module Gitlab
+ class CodeNavigationPath
+ include Gitlab::Utils::StrongMemoize
+ include Gitlab::Routing
+
+ CODE_NAVIGATION_JOB_NAME = 'code_navigation'
+
+ def initialize(project, commit_sha)
+ @project = project
+ @commit_sha = commit_sha
+ end
+
+ def full_json_path_for(path)
+ return if Feature.disabled?(:code_navigation, project)
+ return unless build
+
+ raw_project_job_artifacts_path(project, build, path: "lsif/#{path}.json")
+ end
+
+ private
+
+ attr_reader :project, :commit_sha
+
+ def build
+ strong_memoize(:build) do
+ artifact = ::Ci::JobArtifact
+ .for_sha(commit_sha, project.id)
+ .for_job_name(CODE_NAVIGATION_JOB_NAME)
+ .last
+
+ artifact&.job
+ end
+ end
+ end
+end