<commit_before># # Helpers: SSH helpers
# You don't need to invoke these helpers, they're already invoked automatically.

module Mina
  module SshHelpers

    # ### ssh
    # Executes a command via SSH.
    #
    # Returns nothing usually, but if `{ return: true }` is given, returns the
    # STDOUT output of the SSH session.
    #
    # `options` is a hash of options:
    #
    #  - `:pretty` - Prettify the output if true.
    #  - `:return`  - If set to true, returns the output.
    #
    # Example
    #
    #     ssh("ls", return: true)

    def ssh(cmd, options={})
      require 'shellwords'

      cmd.unshift("export #{env_vars}") if env_vars?
      cmd = cmd.join("\n")  if cmd.is_a?(Array)
      script = Shellwords.escape(cmd)

      if options[:return] == true
        `#{ssh_command} -- #{script}`

      elsif simulate_mode?
        Ssh.simulate(cmd, ssh_command)

      else
        result = Ssh.invoke(script, self)
        Ssh.ensure_successful result, self
      end
    end

    # ### ssh_command
    # Returns the SSH command to be executed.
    #
    #     set :domain, 'foo.com'
    #     set :user, 'diggity'
    #
    #     puts ssh_command
    #     #=> 'ssh <EMAIL>@foo.com'

    def ssh_command
      args = domain!.dup
      args = "#{user}@#{args}" if user?
      args << " -i #{identity_file}" if identity_file?
      args << " -p #{port}" if port?
      args << " -A" if forward_agent?
      args << " #{ssh_options}" if ssh_options?
      args << " -t"
      "ssh #{args}"
    end

    # ## Private methods
    # `ssh` delegates to these.

    module Ssh

      extend self
<commit_msg>force ssh fingerprints adding to known_hosts<commit_after># # Helpers: SSH helpers
# You don't need to invoke these helpers, they're already invoked automatically.

module Mina
  module SshHelpers

    # ### ssh
    # Executes a command via SSH.
    #
    # Returns nothing usually, but if `{ return: true }` is given, returns the
    # STDOUT output of the SSH session.
    #
    # `options` is a hash of options:
    #
    #  - `:pretty` - Prettify the output if true.
    #  - `:return`  - If set to true, returns the output.
    #
    # Example
    #
    #     ssh("ls", return: true)

    def ssh(cmd, options={})
      require 'shellwords'

      cmd.unshift("export #{env_vars}") if env_vars?
      cmd = cmd.join("\n")  if cmd.is_a?(Array)
      script = Shellwords.escape(cmd)

      if options[:return] == true
        `#{ssh_command} -- #{script}`

      elsif simulate_mode?
        Ssh.simulate(cmd, ssh_command)

      else
        result = Ssh.invoke(script, self)
        Ssh.ensure_successful result, self
      end
    end

    # ### ssh_command
    # Returns the SSH command to be executed.
    #
    #     set :domain, 'foo.com'
    #     set :user, 'diggity'
    #
    #     puts ssh_command
    #     #=> 'ssh <EMAIL>@foo.com'

    def ssh_command
      args = domain!.dup
      args = "#{user}@#{args}" if user?
      args << " -i #{identity_file}" if identity_file?
      args << " -p #{port}" if port?
      args << " -A" if forward_agent?
      args << " #{ssh_options}" if ssh_options?
      args << " -o StrictHostKeyChecking=no"
      args << " -t"
      "ssh #{args}"
    end

    # ## Private methods
    # `ssh` delegates to these.

    module Ssh

      extend self

{'fraction_non_alphanumeric': 0.1288380493678507, 'fraction_numerical': 0.0, 'mean_word_length': 2.099813432835821, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 7, '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': '6576947', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1085, 'n_words': 324}