<commit_before>require 'fileutils'
require 'commitphotos/version'
require 'mini_magick'
require 'rest-client'
require 'tempfile'

require 'commitphotos/video'
require 'commitphotos/image'

class CommitPhoto
  # This will setup Commitphotos for the user.
  def self.hook(global, video)
    if global
      destination = File.expand_path(`git config --get init.templatedir`.chomp)
      if destination.empty?
        destination = '~/.gittemplates'
        mkdir_p(destination) unless File.exist?(destination)
        `git config --global init.templatedir #{destination}`
      end
    else
      destination = File.expand_path(File.join(Dir.pwd, '.git/hooks'))
      abort 'Error: not a git repository.' unless File.exist? destination
    end

    type = video ? 'video' : 'image'

    local_post_commit = "#{File.expand_path(File.dirname(__FILE__))}/commitphotos/hooks/post-commit-#{type}"

    FileUtils.copy(local_post_commit, File.join(destination, 'post-commit'))
  end

  def self.image<commit_msg>Fixes bug with .git repo check.<commit_after>require 'fileutils'
require 'commitphotos/version'
require 'mini_magick'
require 'rest-client'
require 'tempfile'

require 'commitphotos/video'
require 'commitphotos/image'

class CommitPhoto
  # This will setup Commitphotos for the user.
  def self.hook(global, video)
    if global
      destination = File.expand_path(`git config --get init.templatedir`.chomp)
      if destination.empty?
        destination = '~/.gittemplates'
        mkdir_p(destination) unless File.exist?(destination)
        `git config --global init.templatedir #{destination}`
      end
    else
      destination = File.expand_path(File.join(Dir.pwd, '.git/hooks'))
      abort 'Error: not a git repository.' unless File.exist? File.join(Dir.pwd, '.git')
    end

    type = video ? 'video' : 'image'

    local_post_commit = "#{File.expand_path(File.dirname(__FILE__))}/commitphotos/hooks/post-commit-#{type}"
    
    FileUtils.mkdir_p(destination)
    FileUtils.copy(local_post_commit, File.join(destination, 'post-commit'))
  end

  def self.image
{'fraction_non_alphanumeric': 0.1188642925890279, 'fraction_numerical': 0.0, 'mean_word_length': 3.768348623853211, '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': '3666679', 'n_tokens_mistral': 646, 'n_tokens_neox': 637, 'n_words': 150}