debian-mirror-gitlab/lib/gitlab/git_ref_validator.rb

18 lines
545 B
Ruby
Raw Normal View History

2017-09-10 17:25:29 +05:30
# Gitaly note: JV: does not need to be migrated, works without a repo.
2015-04-26 12:48:37 +05:30
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)
2017-08-17 22:00:37 +05:30
return false if ref_name.start_with?('refs/heads/')
return false if ref_name.start_with?('refs/remotes/')
2015-04-26 12:48:37 +05:30
Gitlab::Utils.system_silent(
2018-03-17 18:26:18 +05:30
%W(#{Gitlab.config.git.bin_path} check-ref-format --branch #{ref_name}))
2015-04-26 12:48:37 +05:30
end
end
end