<commit_before>#! /usr/bin/ruby

# Opt_parser module, is for getting needed options
module OptParser
  # this is for testing
  class << self; attr_accessor :options; end
  @options = {}
  @options = options.clone if options.any? == true

  def self.raise_verbose_help(msg)
    puts @opt_parser
    puts "************************************************\n"
    raise OptionParser::MissingArgument, msg
  end

  # set some default values
  def self.default_gitbot
    @options[:check] = false if @options[:check].nil?
    @options[:changelog_test] = false if @options[:changelog_test].nil?
    @options[:file_type] = '.changes' if @options[:changelog_test]
    @options[:target_url] = '' if @options[:target_url].nil?
  end

  def self.parse(opt_parser)
    opt_parser.parse!
    OptParser.raise_verbose_help('REPO') if @options[:repo].nil?
    OptParser.raise_verbose_help('CONTEXT') if @options[:context].nil?
    OptParser.raise_verbose_help('DESCRIPTION') if @options[:description].nil?
    OptParser.raise_verbose_help('SCRIPT FILE') if @options[:test_file].nil?
    OptParser.raise_verbose_help('TYPE FILE') if @options[:file_type].nil?
    OptParser.raise_verbose_help('GIT LOCAL DIR') if @options[:git_dir].nil?
    OptParser.default_gitbot
  end

  def self.gitbot_options
    name = './gitbot.rb'
    @opt_parser = OptionParser.new do |opt|
      opt.banner = "************************************************\n" \
        "Usage: gitbot [OPTIONS] \n" \
        " EXAMPLE: ======> #{name} -r openSUSE/gitbot -c \"pysthon-test\" " \
        "-d \"pyflakes_linttest\" -g /tmp/pr-ruby01/ -t /tmp/tests-to-be-executed -f \".py\"\n\n"
      opt.separator 'MANDATORY Options'

      opt.on('-r', "--repo 'REPO'", 'github repo you want to run test against' \
                              ' EXAMPLE: USER/REPO  MalloZup/gitbot') do |repo|
        @options[:repo] = repo
      end

      opt.on('-c', "--context 'CONTEXT'", 'context to set on comment' \
                                  ' EXAMPLE: CONTEXT: python-test') do |context|
        @options[:context] = context
      end

      opt.on('-d', "--description 'DESCRIPTION'", 'description to set on comment') do |description|
        @options[:description] = description
      end

      opt.on('-t', "--test 'TEST.SH'", 'fullpath to the' \
             'script which contain test to be executed against pr') do |test_file|
        @options[:test_file] = test_file<commit_msg>the changelogtest make validation script unneeded<commit_after>#! /usr/bin/ruby

# Opt_parser module, is for getting needed options
module OptParser
  # this is for testing
  class << self; attr_accessor :options; end
  @options = {}
  @options = options.clone if options.any? == true

  def self.raise_verbose_help(msg)
    puts @opt_parser
    puts "************************************************\n"
    raise OptionParser::MissingArgument, msg
  end

  # set some default values
  def self.default_gitbot
    @options[:check] = false if @options[:check].nil?
    @options[:changelog_test] = false if @options[:changelog_test].nil?
    @options[:file_type] = '.changes' if @options[:changelog_test]

    @options[:target_url] = '' if @options[:target_url].nil?
  end

  def self.parse(opt_parser)
    opt_parser.parse!
    OptParser.raise_verbose_help('REPO') if @options[:repo].nil?
    OptParser.raise_verbose_help('CONTEXT') if @options[:context].nil?
    OptParser.raise_verbose_help('DESCRIPTION') if @options[:description].nil?
    OptParser.raise_verbose_help('SCRIPT FILE') if @options[:test_file].nil? && @options[:changelog_test].nil?
    OptParser.raise_verbose_help('TYPE FILE') if @options[:file_type].nil?
    OptParser.raise_verbose_help('GIT LOCAL DIR') if @options[:git_dir].nil?
    OptParser.default_gitbot
  end

  def self.gitbot_options
    name = './gitbot.rb'
    @opt_parser = OptionParser.new do |opt|
      opt.banner = "************************************************\n" \
        "Usage: gitbot [OPTIONS] \n" \
        " EXAMPLE: ======> #{name} -r openSUSE/gitbot -c \"pysthon-test\" " \
        "-d \"pyflakes_linttest\" -g /tmp/pr-ruby01/ -t /tmp/tests-to-be-executed -f \".py\"\n\n"
      opt.separator 'MANDATORY Options'

      opt.on('-r', "--repo 'REPO'", 'github repo you want to run test against' \
                              ' EXAMPLE: USER/REPO  MalloZup/gitbot') do |repo|
        @options[:repo] = repo
      end

      opt.on('-c', "--context 'CONTEXT'", 'context to set on comment' \
                                  ' EXAMPLE: CONTEXT: python-test') do |context|
        @options[:context] = context
      end

      opt.on('-d', "--description 'DESCRIPTION'", 'description to set on comment') do |description|
        @options[:description] = description
      end

      opt.on('-t', "--test 'TEST.SH'", 'fullpath to the' \
             'script which contain test to be executed against pr') do |test_file|
        @options[:test_file] = test_file
{'fraction_non_alphanumeric': 0.17905610694753898, 'fraction_numerical': 0.0008102086287218959, 'mean_word_length': 3.149579831932773, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1827821', 'n_tokens_mistral': 1572, 'n_tokens_neox': 1547, 'n_words': 371}