Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/pipeline/chain/command.rb')
-rw-r--r--lib/gitlab/ci/pipeline/chain/command.rb30
1 files changed, 28 insertions, 2 deletions
diff --git a/lib/gitlab/ci/pipeline/chain/command.rb b/lib/gitlab/ci/pipeline/chain/command.rb
index 8a03789cc3e..626eba97817 100644
--- a/lib/gitlab/ci/pipeline/chain/command.rb
+++ b/lib/gitlab/ci/pipeline/chain/command.rb
@@ -26,13 +26,13 @@ module Gitlab
def branch_exists?
strong_memoize(:is_branch) do
- project.repository.branch_exists?(ref)
+ branch_ref? && project.repository.branch_exists?(ref)
end
end
def tag_exists?
strong_memoize(:is_tag) do
- project.repository.tag_exists?(ref)
+ tag_ref? && project.repository.tag_exists?(ref)
end
end
@@ -106,6 +106,32 @@ module Gitlab
metrics.pipeline_failure_reason_counter
.increment(reason: (reason || :unknown_failure).to_s)
end
+
+ private
+
+ # Verifies that origin_ref is a fully qualified tag reference (refs/tags/<tag-name>)
+ #
+ # Fallbacks to `true` for backward compatibility reasons
+ # if origin_ref is a short ref
+ def tag_ref?
+ return true if full_git_ref_name_unavailable?
+
+ Gitlab::Git.tag_ref?(origin_ref).present?
+ end
+
+ # Verifies that origin_ref is a fully qualified branch reference (refs/heads/<branch-name>)
+ #
+ # Fallbacks to `true` for backward compatibility reasons
+ # if origin_ref is a short ref
+ def branch_ref?
+ return true if full_git_ref_name_unavailable?
+
+ Gitlab::Git.branch_ref?(origin_ref).present?
+ end
+
+ def full_git_ref_name_unavailable?
+ ref == origin_ref
+ end
end
end
end