summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/ci/pipeline/chain/build.rb6
-rw-r--r--lib/gitlab/ci/pipeline/chain/helpers.rb14
2 files changed, 14 insertions, 6 deletions
diff --git a/lib/gitlab/ci/pipeline/chain/build.rb b/lib/gitlab/ci/pipeline/chain/build.rb
index a126dded1ae..d47ebf70068 100644
--- a/lib/gitlab/ci/pipeline/chain/build.rb
+++ b/lib/gitlab/ci/pipeline/chain/build.rb
@@ -3,8 +3,6 @@ module Gitlab
module Pipeline
module Chain
class Build < Chain::Base
- include Chain::Helpers
-
def perform!
@pipeline.assign_attributes(
source: @command.source,
@@ -51,6 +49,10 @@ module Gitlab
def protected_ref?
@project.protected_for?(ref)
end
+
+ def tag_exists?
+ project.repository.tag_exists?(ref)
+ end
end
end
end
diff --git a/lib/gitlab/ci/pipeline/chain/helpers.rb b/lib/gitlab/ci/pipeline/chain/helpers.rb
index 02d81286f21..f6708a849f9 100644
--- a/lib/gitlab/ci/pipeline/chain/helpers.rb
+++ b/lib/gitlab/ci/pipeline/chain/helpers.rb
@@ -3,16 +3,22 @@ module Gitlab
module Pipeline
module Chain
module Helpers
+ include Gitlab::Utils::StrongMemoize
+
def branch_exists?
- return @is_branch if defined?(@is_branch)
+ strong_memoize(:is_branch) do
+ raise ArgumentError unless pipeline.ref
- @is_branch = project.repository.branch_exists?(pipeline.ref)
+ project.repository.branch_exists?(pipeline.ref)
+ end
end
def tag_exists?
- return @is_tag if defined?(@is_tag)
+ strong_memoize(:is_tag) do
+ raise ArgumentError unless pipeline.ref
- @is_tag = project.repository.tag_exists?(pipeline.ref)
+ project.repository.tag_exists?(pipeline.ref)
+ end
end
def error(message)