diff options
Diffstat (limited to 'lib/gitlab/ci/pipeline/chain/helpers.rb')
-rw-r--r-- | lib/gitlab/ci/pipeline/chain/helpers.rb | 14 |
1 files changed, 10 insertions, 4 deletions
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) |