<commit_before>require 'fileutils'

def ipa_path
 File.join(ENV['XCS_OUTPUT_DIR'], ENV['XCS_PRODUCT'])
end

def bot_name
  ENV['XCS_BOT_NAME']
end

def dsym_path_before_zip
  File.join(ENV['XCS_ARCHIVE'], 'dSYMs', 'Tiiny.app.dSYM')
end

def dsym_path_after_zip
  File.join('/tmp', "#{bot_name}.dsym.zip")
end

def hockey_token
  ENV['CMD_HOCKEY_TOKEN']
end

def zip_dsym
  FileUtils.rm_f dsym_path_after_zip
  system '/usr/bin/zip', '-r', dsym_path_after_zip, dsym_path_before_zip
end

def upload
  system(
    '/usr/bin/curl',
    '-F status=2',
    '-F notify=0',
    "-F ipa=@\"#{ipa_path}\"",
    "-F dsym=@\"#{dsym_path_after_zip}\"",
    "-H \"X-HockeyAppToken: #{hockey_token}\"",
    'https://rink.hockeyapp.net/api/2/apps/upload'
  )
end

raise 'Unable to create dsym.zip.' unless zip_dsym
raise 'Upload failed.' unless upload<commit_msg>Debug missing hockey token.<commit_after>require 'fileutils'

def ipa_path
 File.join(ENV['XCS_OUTPUT_DIR'], ENV['XCS_PRODUCT'])
end

def bot_name
  ENV['XCS_BOT_NAME']
end

def dsym_path_before_zip
  File.join(ENV['XCS_ARCHIVE'], 'dSYMs', 'Tiiny.app.dSYM')
end

def dsym_path_after_zip
  File.join('/tmp', "#{bot_name}.dsym.zip")
end

def hockey_token
  ENV['CMD_HOCKEY_TOKEN']
end

def zip_dsym
  FileUtils.rm_f dsym_path_after_zip
  system '/usr/bin/zip', '-r', dsym_path_after_zip, dsym_path_before_zip
end

def upload
  system(
    '/usr/bin/curl',
    '-F status=2',
    '-F notify=0',
    "-F ipa=@\"#{ipa_path}\"",
    "-F dsym=@\"#{dsym_path_after_zip}\"",
    "-H \"X-HockeyAppToken: #{hockey_token}\"",
    'https://rink.hockeyapp.net/api/2/apps/upload'
  )
end

puts hockey_token

raise 'Unable to create dsym.zip.' unless zip_dsym
raise 'Upload failed.' unless upload
{'fraction_non_alphanumeric': 0.16386797915460335, 'fraction_numerical': 0.003474232773595831, 'mean_word_length': 4.366459627329193, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '6093197', 'n_tokens_mistral': 731, 'n_tokens_neox': 730, 'n_words': 134}