BigW Consortium Gitlab

git_ref_validator.rb 541 Bytes
Newer Older
1 2
# Gitaly note: JV: does not need to be migrated, works without a repo.

3 4 5 6 7 8 9
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)
10 11 12
      return false if ref_name.start_with?('refs/heads/')
      return false if ref_name.start_with?('refs/remotes/')

13
      Gitlab::Utils.system_silent(
14
        %W(#{Gitlab.config.git.bin_path} check-ref-format refs/#{ref_name}))
15 16 17
    end
  end
end