gitlab-org--gitlab-foss/lib/gitlab/git_ref_validator.rb

18 lines
545 B
Ruby
Raw Normal View History

2017-07-13 11:58:45 -04:00
# Gitaly note: JV: does not need to be migrated, works without a repo.
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 --branch #{ref_name}))
end
end
end