summaryrefslogtreecommitdiff
path: root/lib/gitlab/git_ref_validator.rb
diff options
context:
space:
mode:
authorAhmad Hassan <ahmad.hassan612@gmail.com>2018-07-17 15:12:29 +0200
committerAhmad Hassan <ahmad.hassan612@gmail.com>2018-07-19 12:23:46 +0200
commit8ea9c81593bd43f38bcafc0ca18408889970cbd6 (patch)
treebebe6c1d314b402a2940f3bccce9fa9cc49ef8bb /lib/gitlab/git_ref_validator.rb
parent59b82fbcd48108682d58426975b581800672ca28 (diff)
downloadgitlab-ce-8ea9c81593bd43f38bcafc0ca18408889970cbd6.tar.gz
Use rugged to validate ref name
Diffstat (limited to 'lib/gitlab/git_ref_validator.rb')
-rw-r--r--lib/gitlab/git_ref_validator.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/gitlab/git_ref_validator.rb b/lib/gitlab/git_ref_validator.rb
index 2e3e4fc3f1f..40636fb204e 100644
--- a/lib/gitlab/git_ref_validator.rb
+++ b/lib/gitlab/git_ref_validator.rb
@@ -7,11 +7,11 @@ module Gitlab
#
# Returns true for a valid reference name, false otherwise
def validate(ref_name)
- return false if ref_name.start_with?('refs/heads/')
- return false if ref_name.start_with?('refs/remotes/')
+ not_allowed_prefixes = %w(refs/heads/ refs/remotes/ -)
+ return false if ref_name.start_with?(*not_allowed_prefixes)
+ return false if ref_name == 'HEAD'
- Gitlab::Utils.system_silent(
- %W(#{Gitlab.config.git.bin_path} check-ref-format --branch #{ref_name}))
+ Rugged::Reference.valid_name? "refs/heads/#{ref_name}"
end
end
end