<commit_before>require 'rubygems'
require 'sinatra'
require 'json'
require 'yaml'
require 'net/http'

CONFIG = YAML.load_file("config.yml")

post '/' do
  push = JSON.parse(params[:payload])
  build_unfuddle_xml_from(push)
end

def build_unfuddle_xml_from(push)
  @repository = push["repository"]
  @commits = push["commits"]
  
  raise "Must specify Unfuddle subdomain, user, and password." unless CONFIG["unfuddle"]["subdomain"] && CONFIG["unfuddle"]["user"] && CONFIG["unfuddle"]["password"]
  raise "Could not map from GitHub project name to Unfuddle Project ID." unless unfuddle_project_id
  
  successes = []
  
  @commits.each do |id, commit|
    timestamp = Time.parse(commit['timestamp'])
    xml = <<-XML
    <changeset>
      #{"<author-id type=\"integer\">#{unfuddle_author_id(commit)}</author-id>" if unfuddle_author_id(commit)}
      <message>#{commit["message"]}
      
Details: #{commit["url"]}</message>
      <revision type="integer">#{timestamp.strftime("%y%m%d%H%M")}</revision>
    </changeset>
    XML
    
    successes << post_changeset_to_unfuddle(xml)
  end
  <commit_msg>Seeing what happens without a revision number.<commit_after>require 'rubygems'
require 'sinatra'
require 'json'
require 'yaml'
require 'net/http'

CONFIG = YAML.load_file("config.yml")

post '/' do
  push = JSON.parse(params[:payload])
  build_unfuddle_xml_from(push)
end

def build_unfuddle_xml_from(push)
  @repository = push["repository"]
  @commits = push["commits"]
  
  raise "Must specify Unfuddle subdomain, user, and password." unless CONFIG["unfuddle"]["subdomain"] && CONFIG["unfuddle"]["user"] && CONFIG["unfuddle"]["password"]
  raise "Could not map from GitHub project name to Unfuddle Project ID." unless unfuddle_project_id
  
  successes = []
  
  @commits.each do |id, commit|
    timestamp = Time.parse(commit['timestamp'])
    xml = <<-XML
    <changeset>
      #{"<author-id type=\"integer\">#{unfuddle_author_id(commit)}</author-id>" if unfuddle_author_id(commit)}
      <message>#{commit["message"]}
      
Details: #{commit["url"]}</message>
    </changeset>
    XML
    
    #<revision type="integer">#{timestamp.strftime("%y%m%d%H%M")}</revision>
    
    successes << post_changeset_to_unfuddle(xml)
  end
  
{'fraction_non_alphanumeric': 0.1594267801164353, 'fraction_numerical': 0.0, 'mean_word_length': 4.684478371501272, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '5129885', 'n_tokens_mistral': 773, 'n_tokens_neox': 762, 'n_words': 154}