Commit 9776dbda authored by Grzegorz Bizon's avatar Grzegorz Bizon

Use tag/branch methods to check if pipeline ref exists

parent 8f47d484
...@@ -107,8 +107,7 @@ module Ci ...@@ -107,8 +107,7 @@ module Ci
def tag? def tag?
return @is_tag if defined?(@is_tag) return @is_tag if defined?(@is_tag)
@is_tag = @is_tag = project.repository.tag_exists?(ref)
project.repository.ref_exists?(Gitlab::Git::TAG_REF_PREFIX + ref)
end end
def ref def ref
...@@ -120,7 +119,8 @@ module Ci ...@@ -120,7 +119,8 @@ module Ci
end end
def pipeline_created_counter def pipeline_created_counter
@pipeline_created_counter ||= Gitlab::Metrics.counter(:pipelines_created_total, "Counter of pipelines created") @pipeline_created_counter ||= Gitlab::Metrics
.counter(:pipelines_created_total, "Counter of pipelines created")
end end
end end
end end
...@@ -79,22 +79,16 @@ module Gitlab ...@@ -79,22 +79,16 @@ module Gitlab
end end
end end
## TODO, move to Pipeline as `branch_exists?`
#
def branch? def branch?
return @is_branch if defined?(@is_branch) return @is_branch if defined?(@is_branch)
@is_branch = project.repository @is_branch = project.repository.branch_exists?(pipeline.ref)
.ref_exists?(Gitlab::Git::BRANCH_REF_PREFIX + pipeline.ref)
end end
## TODO, move to pipeline as `tag_exists?`
#
def tag? def tag?
return @is_tag if defined?(@is_tag) return @is_tag if defined?(@is_tag)
@is_tag = project.repository @is_tag = project.repository.tag_exists?(pipeline.ref)
.ref_exists?(Gitlab::Git::TAG_REF_PREFIX + pipeline.ref)
end end
def error(message) def error(message)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment