gitlab-org--gitlab-foss/lib/gitlab/git_ref_validator.rb
Matthieu Tardy 7a399b7061 Strip reference prefixes on branch creation
Signed-off-by: Matthieu Tardy <matthieu.tardy@gmail.com>
2017-01-09 13:38:44 +01:00

15 lines
469 B
Ruby

module Gitlab
module GitRefValidator
extend self
# Validates a given name against the git reference specification
#
# 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/')
Gitlab::Utils.system_silent(
%W(#{Gitlab.config.git.bin_path} check-ref-format refs/#{ref_name}))
end
end
end