Method: Gitlab::GitRefValidator#validate
- Defined in:
- lib/gitlab/git_ref_validator.rb
#validate(ref_name, skip_head_ref_check: false) ⇒ Object
Validates a given name against the git reference specification
Returns true for a valid reference name, false otherwise
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gitlab/git_ref_validator.rb', line 15 def validate(ref_name, skip_head_ref_check: false) return false if ref_name.to_s.empty? # #blank? raises an ArgumentError for invalid encodings return false if ref_name.start_with?(*(EXPANDED_PREFIXES + DISALLOWED_PREFIXES)) return false if ref_name == 'HEAD' && !skip_head_ref_check begin Rugged::Reference.valid_name?("refs/heads/#{ref_name}") rescue ArgumentError false end end |