<commit_before>require_relative 'gitlab_init'
require_relative 'gitlab_net'

class GitlabUpdate
  def initialize(repo_path, key_id, refname)
    @repo_name = repo_path
    @repo_name.gsub!(GitlabConfig.new.repos_path.to_s, "")
    @repo_name.gsub!(/.git$/, "")
    @repo_name.gsub!(/^\//, "")

    @key_id = key_id
    @refname = /refs\/heads\/([\w\.-]+)/.match(refname).to_a.last
  end

  def exec
    if api.allowed?('git-receive-pack', @repo_name, @key_id, @refname)
      exit 0
    else
      puts "GitLab: You are not allowed to access #{@refname}! "
      exit 1
    end
  end

  protected

  def api
    GitlabNet.new
  end
end<commit_msg>Allow local pushes without update check<commit_after>require_relative 'gitlab_init'
require_relative 'gitlab_net'

class GitlabUpdate
  def initialize(repo_path, key_id, refname)
    @repo_name = repo_path
    @repo_name.gsub!(GitlabConfig.new.repos_path.to_s, "")
    @repo_name.gsub!(/.git$/, "")
    @repo_name.gsub!(/^\//, "")

    @key_id = key_id
    @refname = /refs\/heads\/([\w\.-]+)/.match(refname).to_a.last
  end

  def exec
    # Skip update hook for local push when key_id is nil
    # It required for gitlab instance to make local pushes
    # without validation of access
    exit 0 if @key_id.nil?

    if api.allowed?('git-receive-pack', @repo_name, @key_id, @refname)
      exit 0
    else
      puts "GitLab: You are not allowed to access #{@refname}! "
      exit 1
    end
  end

  protected

  def api
    GitlabNet.new
  end
end
{'fraction_non_alphanumeric': 0.13208805870580387, 'fraction_numerical': 0.00333555703802535, 'mean_word_length': 2.9682539682539684, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '311782', 'n_tokens_mistral': 569, 'n_tokens_neox': 542, 'n_words': 129}