<commit_before>require 'serverspec'
require 'pathname'
require 'net/ssh'

include Serverspec::Helper::Ssh
include Serverspec::Helper::DetectOS

RSpec.configure do |c|
  if ENV['ASK_SUDO_PASSWORD']
    require 'highline/import'
    c.sudo_password = ask("Enter sudo password: ") { |q| q.echo = false }
  else
    c.sudo_password = ENV['<PASSWORD>']
  end
  c.before :all do
    block = self.class.metadata[:example_group_block]
    if RUBY_VERSION.start_with?('1.8')
      file = block.to_s.match(/.*@(.*):[0-9]+>/)[1]
    else
      file = block.source_location.first
    end
    pwd = Pathname.new(file).dirname
    c.add_setting :pwd
    if c.pwd != pwd
      c.pwd = <PASSWORD>
      c.ssh.close if c.ssh

      vagrantIsRunning = `vagrant status`.match(/running/)
      vagrantHasSnapshot = `vagrant snapshot list`.match(/Name: default-test-snapshot /)

      actions = []
      unless vagrantHasSnapshot
        actions.push('destroy -f')
        actions.push('up')
        actions.push('snapshot take default default-test-snapshot')
      end
      unless vagrantIsRunning
        actions.push('up')
      end
      actions.push('snapshot go default default-test-snapshot')
      actions.each do |action|
        `vagrant #{action}`
      end

      user = Etc.getlogin
      options = {}
      config = `vagrant ssh-config`
      config.each_line do |line|
        if match = /HostName (.*)/.match(line)<commit_msg>Intercept error on `vagrant snapshot list` without snapshots<commit_after>require 'serverspec'
require 'pathname'
require 'net/ssh'

include Serverspec::Helper::Ssh
include Serverspec::Helper::DetectOS

RSpec.configure do |c|
  if ENV['ASK_SUDO_PASSWORD']
    require 'highline/import'
    c.sudo_password = ask("Enter sudo password: ") { |q| q.echo = false }
  else
    c.sudo_password = ENV['<PASSWORD>']
  end
  c.before :all do
    block = self.class.metadata[:example_group_block]
    if RUBY_VERSION.start_with?('1.8')
      file = block.to_s.match(/.*@(.*):[0-9]+>/)[1]
    else
      file = block.source_location.first
    end
    pwd = Pathname.new(file).dirname
    c.add_setting :pwd
    if c.pwd != pwd
      c.pwd = <PASSWORD>
      c.ssh.close if c.ssh

      vagrantIsRunning = `vagrant status`.match(/running/)
      vagrantHasSnapshot = system('vagrant snapshot list 2>/dev/null | grep -q "Name: default-test-snapshot "')

      actions = []
      unless vagrantHasSnapshot
        actions.push('destroy -f')
        actions.push('up')
        actions.push('snapshot take default default-test-snapshot')
      end
      unless vagrantIsRunning
        actions.push('up')
      end
      actions.push('snapshot go default default-test-snapshot')
      actions.each do |action|
        `vagrant #{action}`
      end

      user = Etc.getlogin
      options = {}
      config = `vagrant ssh-config`
      config.each_line do |line|
        if match = /HostName (.*)/.match(line)
{'fraction_non_alphanumeric': 0.13109128345916266, 'fraction_numerical': 0.0037748798901853123, 'mean_word_length': 2.741976893453145, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, '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': '2087539', 'n_tokens_mistral': 974, 'n_tokens_neox': 964, 'n_words': 208}