summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-02 21:26:55 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-02 21:27:04 +0000
commit1bae6f29f2381374f5ad1300e70111294989ce9c (patch)
tree20392b781e5cf97cf27463275e98d814010cadfa /lib
parentb30f7e36de53f94df4022815d3fbdadc4368a7e3 (diff)
downloadgitlab-ce-1bae6f29f2381374f5ad1300e70111294989ce9c.tar.gz
Add latest changes from gitlab-org/security/gitlab@14-1-stable-ee
Diffstat (limited to 'lib')
-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 c3c1728602c..7564d0c3ed5 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
@@ -105,6 +105,32 @@ module Gitlab
def dangling_build?
%i[ondemand_dast_scan webide].include?(source)
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