summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/pipeline/chain/helpers.rb
blob: f6708a849f9d1cff26b1fb0c364319f9bc696ee1 (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
module Gitlab
  module Ci
    module Pipeline
      module Chain
        module Helpers
          include Gitlab::Utils::StrongMemoize

          def branch_exists?
            strong_memoize(:is_branch) do
              raise ArgumentError unless pipeline.ref

              project.repository.branch_exists?(pipeline.ref)
            end
          end

          def tag_exists?
            strong_memoize(:is_tag) do
              raise ArgumentError unless pipeline.ref

              project.repository.tag_exists?(pipeline.ref)
            end
          end

          def error(message)
            pipeline.errors.add(:base, message)
          end
        end
      end
    end
  end
end