2017-07-13 11:58:45 -04:00
|
|
|
# Gitaly note: JV: does not need to be migrated, works without a repo.
|
|
|
|
|
2014-07-27 10:40:00 -04:00
|
|
|
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-01-09 01:38:13 -05:00
|
|
|
return false if ref_name.start_with?('refs/heads/')
|
|
|
|
return false if ref_name.start_with?('refs/remotes/')
|
|
|
|
|
2014-11-06 06:07:16 -05:00
|
|
|
Gitlab::Utils.system_silent(
|
2017-10-05 11:05:48 -04:00
|
|
|
%W(#{Gitlab.config.git.bin_path} check-ref-format --branch #{ref_name}))
|
2014-07-27 10:40:00 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|