<commit_before>
class GithubCommon

  def initialize
  end

  def config_githib
    return unless @username.nil?
    @api_endpoint = ask('What is the API endpoint?') { |q| q.default = 'https://github.uc.edu/api/v3' }
    @web_endpoint = ask("What is the Web endpoint?") { |q| q.default = 'https://github.uc.edu/' }

    @username = ask('What is your username? (You must be an owner for the organization)?') { |q| q.default = ENV['USER'] }
    @password = ask('What is your password?') { |q| q.echo = false }
  end

  def init_client
    config_githib()
    puts "=" * 50
    puts "Authenticating to github..."
    Octokit.configure do |c|
      c.api_endpoint = @api_endpoint
      c.web_endpoint = @web_endpoint
    end
    @client = Octokit::Client.new(:login => @username, :password => <PASSWORD>)
  end

  def read_organization(organization)
    abort("Githib client not initialized") if @client.nil?
    @client.organization(organization)
  end

  protected
  def get_existing_repos_by_names(organization)
    repos = Hash.new
    @client.organization_repositories(organization).each do |repo|
      repos[repo[:name]] = repo
    end
    return repos<commit_msg>added support for oauth authentication in client<commit_after>
class GithubCommon

  def initialize
  end

  def config_githib
    return unless @username.nil?
    @api_endpoint = ask('What is the API endpoint?') { |q| q.default = 'https://github.uc.edu/api/v3' }
    @web_endpoint = ask("What is the Web endpoint?") { |q| q.default = 'https://github.uc.edu/' }

    @username = ask('What is your username? (You must be an owner for the organization)?') { |q| q.default = ENV['USER'] }

    choose do |menu|
      menu.prompt = "Login via oAuth or Password? "
      menu.choice :oAuth do
        @authmethod = 'oauth'
      end 
      menu.choice :Password do 
        @authmethod = 'password'
      end 
    end

    if @authmethod == 'oauth'
        @oauthtoken = ask('What is your oAuth token?') { |q| q.default = ENV['ghe_oauth'] }
    end
    if @authmethod == 'password'
        @password = ask('What is your password?') { |q| q.echo = false }
    end
  end

  def init_client
    config_githib()
    puts "=" * 50
    puts "Authenticating to github..."
    Octokit.configure do |c|
      c.api_endpoint = @api_endpoint
      c.web_endpoint = @web_endpoint
    end
 
    if @authmethod == 'password'
      @client = Octokit::Client.new(:login => @username, :password => <PASSWORD>) 
    end
    if @authmethod == 'oauth'
      @client = Octokit::Client.new(:login => @username, :oauth_token => @oauthtoken) 
    end
  end

  def read_organization(organization)
    abort("Githib client not initialized") if @client.nil?
    @client.organization(organization)
  end

  protected
  def get_existing_repos_by_names(organization)
    repos = Hash.new
    @client.organization_repositories(organization).each do |repo|
      repos[repo[:name]] = repo
    end
    return repos
{'fraction_non_alphanumeric': 0.12572205232755693, 'fraction_numerical': 0.0020387359836901123, 'mean_word_length': 3.0775623268698062, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 4, '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': '3550641', 'n_tokens_mistral': 982, 'n_tokens_neox': 934, 'n_words': 257}