<commit_before>require 'fileutils'

module PurolandGreeting
  class GitBackuper
    def run(today = nil, now = nil, registered = nil, diff = nil)
      return if !diff || diff.empty?

      ltsv = Database.export_by_date(today)

      Dir.chdir('shared/puroland-greeting-schedule') do
        file = "#{today.strftime('%F')}.ltsv"
        dir = today.strftime('%Y/%m')
        FileUtils.mkdir_p dir
        path = "#{dir}/#{file}"
        open(path, 'w') do |f|
          f << ltsv
        end
        message = "#{registered ? 'Add' : 'Update'} #{file}"
        system "git add '#{path}' && git commit -m '#{message}'"
        if private_key = ENV['SSH_PRIVATE_KEY_PATH']
          system %{ssh-agent sh -c "ssh-add #{private_key} && git push origin master"}
        end
      end
    end
  end
end<commit_msg>Specify author<commit_after>require 'fileutils'

module PurolandGreeting
  class GitBackuper
    def run(today = nil, now = nil, registered = nil, diff = nil)
      return if !diff || diff.empty?

      ltsv = Database.export_by_date(today)

      Dir.chdir('shared/puroland-greeting-schedule') do
        file = "#{today.strftime('%F')}.ltsv"
        dir = today.strftime('%Y/%m')
        FileUtils.mkdir_p dir
        path = "#{dir}/#{file}"
        open(path, 'w') do |f|
          f << ltsv
        end
        message = "#{registered ? 'Add' : 'Update'} #{file}"
        system "git add '#{path}' && git commit -m '#{message}' --author='mono <<EMAIL>>'"
        if private_key = ENV['SSH_PRIVATE_KEY_PATH']
          system %{ssh-agent sh -c "ssh-add #{private_key} && git push origin master"}
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.15221346270466948, 'fraction_numerical': 0.0, 'mean_word_length': 2.409090909090909, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5268207', 'n_tokens_mistral': 570, 'n_tokens_neox': 553, 'n_words': 140}