<commit_before>class Hookup

  class Error < RuntimeError
  end

  EMPTY_DIR = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'

  def self.run(*argv)
    new.run(*argv)
  rescue Error => e
    puts e
    exit
  end

  def run(*argv)
    if argv.empty?
      install
    else
      command = argv.shift
      begin
        send(command.tr('-', '_'), *argv)
      rescue NoMethodError
        raise Error, "Unknown command #{command}"
      rescue ArgumentError
        raise Error, "Invalid arguments for #{command}"
      end
    end
  end

  def install
    dir = %x{git rev-parse --git-dir}.chomp
    raise Error, dir unless $?.success?
    hook = File.join(dir, 'hooks', 'post-checkout')
    unless File.exist?(hook)
      File.open(hook, 'w', 0777) do |f|
        f.puts "#!/bin/bash"
      end
    end
    if File.read(hook) =~ /^[^#]*\bhookup\b/
      puts "Already hooked up!"
    else
      File.open(hook, "a") do |f|
        f.puts %(hookup post-checkout "$@")
      end
      puts "Hooked up!"<commit_msg>Tell Hookup to make hooks dir if it doesn't exist<commit_after>class Hookup

  class Error < RuntimeError
  end

  EMPTY_DIR = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'

  def self.run(*argv)
    new.run(*argv)
  rescue Error => e
    puts e
    exit
  end

  def run(*argv)
    if argv.empty?
      install
    else
      command = argv.shift
      begin
        send(command.tr('-', '_'), *argv)
      rescue NoMethodError
        raise Error, "Unknown command #{command}"
      rescue ArgumentError
        raise Error, "Invalid arguments for #{command}"
      end
    end
  end

  def install
    dir = %x{git rev-parse --git-dir}.chomp
    raise Error, dir unless $?.success?

    hook_dir = File.join(dir, 'hooks')
    Dir.mkdir(hook_dir, 0755) unless Dir.exists?(hook_dir)

    hook = File.join(hook_dir, 'post-checkout')

    unless File.exist?(hook)
      File.open(hook, 'w', 0777) do |f|
        f.puts "#!/bin/bash"
      end
    end
    if File.read(hook) =~ /^[^#]*\bhookup\b/
      puts "Already hooked up!"
    else
      File.open(hook, "a") do |f|
        f.puts %(hookup post-checkout "$@")
      end
      puts "Hooked up!"
{'fraction_non_alphanumeric': 0.128538283062645, 'fraction_numerical': 0.027842227378190254, 'mean_word_length': 2.2716236722306524, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '860497', 'n_tokens_mistral': 802, 'n_tokens_neox': 758, 'n_words': 198}