diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-12-08 10:50:10 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-12-08 10:50:10 +0100 |
commit | b30e0e0691716c2ef0b858b81dd5cef8d4728c59 (patch) | |
tree | 658af97734ba537da94ed1156f108248cfaad952 /lib/gitlab/ci | |
parent | fe62860e05ca6e3ef7125fe92fdf52cd6f7b63df (diff) | |
download | gitlab-ce-b30e0e0691716c2ef0b858b81dd5cef8d4728c59.tar.gz |
Fix invalid pipeline build chain tag evaluation
Diffstat (limited to 'lib/gitlab/ci')
-rw-r--r-- | lib/gitlab/ci/pipeline/chain/build.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/ci/pipeline/chain/helpers.rb | 14 |
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) |