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


user = ""
password = ""

unless ARGV[0]
  puts "Usage: #{$O} [folderBackup]"
  exit
end

folderBackup = ARGV[0]

client = Octokit::Client.new(:login => user, :password => password)

orgName = 'zauberlabs'

if !File.directory?(folderBackup)
        Dir.mkdir(folderBackup)
end

client.repositories(orgName).each { |repo|
    dirName = File.join(folderBackup, repo.name)
    if !File.directory?(dirName)
        Dir.mkdir(dirName)
    end
    ['open', 'closed'].each { |status|
        page = 0

        ## navego las multiples paginas
        begin
            issues = client.list_issues("%s/%s" % [orgName, repo.name], {
                 :page  => page, 
                 :state => status
            })
            issues.each { |issue|
                 ## file where the issue is saved
                 issueFilename = '%s/%04d.js' % [dirName,issue.number]
                 json = JSON.pretty_generate(client.issue("%s/%s" % [orgName, repo.name], issue.number))
                 File.open(issueFilename , 'w') {|f| f.write(json) }
            }
            page = page + 1
        end until issues.length != 10
    }

}

<commit_msg>Downloads and commits all issues to a local git repository<commit_after>#!/usr/bin/env ruby
require 'rubygems'
require 'octokit'
require 'json'
require 'grit'
include Grit

user = ""
password = ""

unless ARGV[0]
  puts "Usage: #{$O} [folderBackup]"
  exit
end

folderBackup = ARGV[0]

client = Octokit::Client.new(:login => user, :password => password)

orgName = 'zauberlabs'

if !File.directory?(folderBackup)
    puts "The directory '" + folderBackup + "' doesn't exist"
    exit!
end

client.repositories(orgName).each { |repo|
    puts "Backuping " + repo.name
    dirName = File.join(folderBackup, repo.name)
    if !File.directory?(dirName)
        Dir.mkdir(dirName)
    end
    
    repoName = "%s/%s" % [orgName, repo.name]

    if client.repository(repoName).has_issues
	    ['open', 'closed'].each { |status|
		page = 0

		## navego las multiples paginas
		begin
		    issues = client.list_issues(repoName, {
		         :page  => page, 
		         :state => status
		    })
		    issues.each { |issue|
		         ## file where the issue is saved
		         issueFilename = '%s/%04d.js' % [dirName,issue.number]
		         json = JSON.pretty_generate(client.issue(repoName, issue.number))
		         File.open(issueFilename , 'w') {|f| f.write(json) }
		    }
		    page = page + 1
		end until issues.length != 10
	    }
    else
	puts '    Ignore %s project without issues' % repoName
    end
}

puts 'Commiting...'
repo = Repo.new(folderBackup)
Dir.chdir(folderBackup)
repo.add(".")
repo.commit_index("Backup...")
puts 'Finish commit...'
{'fraction_non_alphanumeric': 0.1415706051873199, 'fraction_numerical': 0.005763688760806916, 'mean_word_length': 2.4974811083123427, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2784479', 'n_tokens_mistral': 960, 'n_tokens_neox': 916, 'n_words': 213}