<commit_before>#!/usr/bin/env ruby
require 'rubygems'
require 'git'

def dir_is_syncable(dir)
  begin
    g = Git.open(dir)
    origin_exists = false
    g.remotes.each do |remote|
      origin_exists = true if !origin_exists && remote.name == 'origin' && !remote.url.match(/github/).nil?
    end
    origin_exists
  rescue ArgumentError
    puts "Not a git repo, sorry!"
    false
  end
end

while dir_is_syncable(Dir.pwd) do
  g = Git.open(Dir.pwd)

  g.status.each do |file|
    if file.untracked || !file.type.nil?

      if file.type == "D"
        g.remove file.path
      else
        g.add file.path
      end

      message =
        if file.untracked
          # Untracked files don’t have a type of 'A' before being staged,
          # and at the point we run `status` we haven’t staged anything yet.
          "Auto-sync: A - #{file.path}"
        else
          "Auto-sync: #{file.type} - #{file.path}"
        end

      puts "#{message}. Syncing…"
      g.commit message
      g.push('origin')
      puts "Done."
    end
  end

  g.pull('origin')
<commit_msg>Auto-sync: M - sink.rb<commit_after>#!/usr/bin/env ruby
require 'rubygems'
require 'git'
require 'octokit'
require 'dotenv'

Dotenv.load

def dir_is_syncable(dir)
  begin
    g = Git.open(dir)
    origin_exists = false
    g.remotes.each do |remote|
      origin_exists = true if !origin_exists && remote.name == 'origin' && !remote.url.match(/github/).nil?
    end
    origin_exists
  rescue ArgumentError
    puts "Not a git repo, sorry!"
    false
  end
end

github = Octokit::Client.new(:access_token => ENV["GITHUB_TOKEN"])

while dir_is_syncable(Dir.pwd) do
  g = Git.open(Dir.pwd)

  g.status.each do |file|
    if file.untracked || !file.type.nil?

      if file.type == "D"
        g.remove file.path
      else
        g.add file.path
      end

      message =
        if file.untracked
          # Untracked files don’t have a type of 'A' before being staged,
          # and at the point we run `status` we haven’t staged anything yet.
          "Auto-sync: A - #{file.path}"
        else
          "Auto-sync: #{file.type} - #{file.path}"
        end

      puts "#{message}. Syncing…"
      g.commit message
      g.push('origin')
      puts "Done."
    end
  end

  g.pull('origin')

{'fraction_non_alphanumeric': 0.12406511218653761, 'fraction_numerical': 0.0, 'mean_word_length': 2.19831223628692, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '5838755', 'n_tokens_mistral': 797, 'n_tokens_neox': 785, 'n_words': 212}