<commit_before>module MGit
  class FetchCommand < Command
    def execute(args)
      Registry.chdir_each do |repo|
        `git remote`.split.each do |remote|
          pinfo "Fetching #{remote} in repository #{repo.name}..."
          `git fetch #{remote}`
        end
      end
    end

    def arity
      [nil, 0]
    end

    def usage
      'fetch'
    end

    def description
      'fetch all remote repositories'
    end

    register_command :fetch
  end
end<commit_msg>Fetch uses threads now per repo.<commit_after>require 'open3'

module MGit
  class FetchCommand < Command
    def execute(args)
      threads = []
      Registry.each do |repo|
        threads << Thread.new do
          remotes, st = Open3.capture2('git remote', :chdir => repo.path)

          if st.exitstatus != 0
            perror "Failed to read remotes for repository #{repo.name}! Abort." 
            Thread.exit
          end

          remotes.split.each do |remote|
            sout, st = Open3.capture2("git fetch #{remote}", :chdir => repo.path)
            if st.exitstatus == 0
              pinfo "Fetched #{remote} in repository #{repo.name}."
            else
              perror "Failed to fetch #{remote} in repository #{repo.name}! Abort."
              break
            end
          end
        end
      end

      threads.each { |t| t.join }
    end

    def arity
      [nil, 0]
    end

    def usage
      'fetch'
    end

    def description
      'fetch all remote repositories'
    end

    register_command :fetch
  end
end
{'fraction_non_alphanumeric': 0.0903183885640026, 'fraction_numerical': 0.005847953216374269, 'mean_word_length': 1.7256637168141593, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7628711', 'n_tokens_mistral': 462, 'n_tokens_neox': 440, 'n_words': 144}