<commit_before>module Dapp
  # Project
  class Project
    module SystemShellout
      SYSTEM_SHELLOUT_IMAGE = 'ubuntu:16.04'.freeze

      def system_shellout(command, raise_error: false, **kwargs)
        system_shellout_extra(volume: (git_path ? File.dirname(git_path) : path)) do
          begin
            if raise_error
              shellout! _to_system_shellout_command(command), **kwargs
            else
              shellout _to_system_shellout_command(command), **kwargs
            end
          rescue Error::Shellout
            log_info(
              desc: { code: :launched_command,
                      data: { command: _to_system_shellout_command(command) },
                      context: :system_shellout },
              quiet: !log_verbose?
            )
            raise
          end
        end
      end

      def system_shellout!(command, **kwargs)
        system_shellout(command, raise_error: true, **kwargs)
      end

      def system_shellout_extra(volume: [], workdir: nil, &blk)
        old = system_shellout_opts.dup

        system_shellout_opts[:volume] += Array(volume)
        system_shellout_opts[:workdir] = workdir if workdir

        yield if block_given?
      ensure
        @system_shellout_opts = old
      end

      protected

      def system_shellout_opts
        @system_shellout_opts ||= {volume: []}
      end

      def _to_system_shellout_command(command)
        volumes_from = [base_container, gitartifact_container]

        ['docker run',
         '--rm',
         "--workdir #{system_shellout_opts[:workdir] || Dir.pwd}",
         *volumes_from.map { |container| "--volumes-from #{container}" },
         *Array(system_shellout_opts[:volume]).map { |volume| "--volume #{volume}:#{volume}" },
         *SystemShellout.default_env_keys.map { |env_key|
           env_key = env_key.to_s.upcase
           "--env #{env_key}=#{ENV[env_key]}"
         },
         SYSTEM_SHELLOUT_IMAGE,
         "#{bash_bin} -ec '#{shellout_pack(command)}'"
        ].join(' ')
      end

      class << self
        def default_env_keys
          @default_env_keys ||= []
        end
      end # << self
    end # SystemShellout
  end # Project
end # Dapp
<commit_msg>Print system-shellout failed command always, not in verbose only<commit_after>module Dapp
  # Project
  class Project
    module SystemShellout
      SYSTEM_SHELLOUT_IMAGE = 'ubuntu:16.04'.freeze

      def system_shellout(command, raise_error: false, **kwargs)
        system_shellout_extra(volume: (git_path ? File.dirname(git_path) : path)) do
          begin
            if raise_error
              shellout! _to_system_shellout_command(command), **kwargs
            else
              shellout _to_system_shellout_command(command), **kwargs
            end
          rescue Error::Shellout
            log_info(
              desc: { code: :launched_command,
                      data: { command: _to_system_shellout_command(command) },
                      context: :system_shellout },
              quiet: false
            )
            raise
          end
        end
      end

      def system_shellout!(command, **kwargs)
        system_shellout(command, raise_error: true, **kwargs)
      end

      def system_shellout_extra(volume: [], workdir: nil, &blk)
        old = system_shellout_opts.dup

        system_shellout_opts[:volume] += Array(volume)
        system_shellout_opts[:workdir] = workdir if workdir

        yield if block_given?
      ensure
        @system_shellout_opts = old
      end

      protected

      def system_shellout_opts
        @system_shellout_opts ||= {volume: []}
      end

      def _to_system_shellout_command(command)
        volumes_from = [base_container, gitartifact_container]

        ['docker run',
         '--rm',
         "--workdir #{system_shellout_opts[:workdir] || Dir.pwd}",
         *volumes_from.map { |container| "--volumes-from #{container}" },
         *Array(system_shellout_opts[:volume]).map { |volume| "--volume #{volume}:#{volume}" },
         *SystemShellout.default_env_keys.map { |env_key|
           env_key = env_key.to_s.upcase
           "--env #{env_key}=#{ENV[env_key]}"
         },
         SYSTEM_SHELLOUT_IMAGE,
         "#{bash_bin} -ec '#{shellout_pack(command)}'"
        ].join(' ')
      end

      class << self
        def default_env_keys
          @default_env_keys ||= []
        end
      end # << self
    end # SystemShellout
  end # Project
end # Dapp

{'fraction_non_alphanumeric': 0.104180639391907, 'fraction_numerical': 0.001788508830762352, 'mean_word_length': 2.102635228848821, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, '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': '7040482', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1304, 'n_words': 260}