Welcome to mirror list, hosted at ThFree Co, Russian Federation.

base.rb « context « build « ci « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c7ea7c78e2f39b42d7d3da6bcb16e7d0a483413b (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# frozen_string_literal: true

module Gitlab
  module Ci
    module Build
      module Context
        class Base
          include Gitlab::Utils::StrongMemoize

          attr_reader :pipeline

          def initialize(pipeline)
            @pipeline = pipeline
          end

          def variables
            raise NotImplementedError
          end

          def project
            pipeline.project
          end

          def sha
            pipeline.sha
          end

          def top_level_worktree_paths
            strong_memoize(:top_level_worktree_paths) do
              project.repository.tree(sha).blobs.map(&:path)
            end
          end

          def all_worktree_paths
            strong_memoize(:all_worktree_paths) do
              project.repository.ls_files(sha)
            end
          end

          protected

          def pipeline_attributes
            {
              pipeline: pipeline,
              project: pipeline.project,
              user: pipeline.user,
              ref: pipeline.ref,
              tag: pipeline.tag,
              trigger_request: pipeline.legacy_trigger,
              protected: pipeline.protected_ref?
            }
          end
        end
      end
    end
  end
end