<commit_before>require 'formula'

module Homebrew extend self
  def versions
    raise "Please `brew install git` first" unless which "git"
    raise "Please `brew update' first" unless (HOMEBREW_REPOSITORY/".git").directory?

    raise FormulaUnspecifiedError if ARGV.named.empty?

    ARGV.formulae.all? do |f|
      if ARGV.include? '--compact'
        puts f.versions * " "
      else
        f.versions do |version, sha|
          print Tty.white.to_s
          print "#{version.to_s.ljust(8)} "
          print Tty.reset.to_s
          puts "git checkout #{sha} #{f.pretty_relative_path}"
        end
      end
    end
  end
end


class Formula
  def versions
    versions = []
    rev_list.each do |sha|
      version = version_for_sha sha
      unless versions.include? version or version.nil?
        yield version, sha if block_given?
        versions << version
      end
    end
    return versions
  end

  def bottle_filenames branch='HEAD'
    filenames = []
    rev_list(branch).each do |sha|
      filename = formula_for_sha(sha) {|f| bottle_filename f }
      unless filenames.include? filename or filename.nil?
        filenames << filename
      end
    end
    return filenames
  end

  def pretty_relative_path
    if Pathname.pwd == repository
      entry_name
    else
      repository/"#{entry_name}"
    end
  end

  private
    def repository
      @repository ||= begin
        if path.realpath.to_s =~ %r{#{HOMEBREW_REPOSITORY}/Library/Taps/(\w+)-(\w+)}
          HOMEBREW_REPOSITORY/"Library/Taps/#$1-#$2"
        else
          HOMEBREW_REPOSITORY
        end
      end
    end

    def entry_name
      @entry_name ||= begin
        repository == HOMEBREW_REPOSITORY ? "Library/Formula/#{name}.rb" : "#{name}.rb"
      end<commit_msg>versions: use bottle_filename only if f.bottle.<commit_after>require 'formula'

module Homebrew extend self
  def versions
    raise "Please `brew install git` first" unless which "git"
    raise "Please `brew update' first" unless (HOMEBREW_REPOSITORY/".git").directory?

    raise FormulaUnspecifiedError if ARGV.named.empty?

    ARGV.formulae.all? do |f|
      if ARGV.include? '--compact'
        puts f.versions * " "
      else
        f.versions do |version, sha|
          print Tty.white.to_s
          print "#{version.to_s.ljust(8)} "
          print Tty.reset.to_s
          puts "git checkout #{sha} #{f.pretty_relative_path}"
        end
      end
    end
  end
end


class Formula
  def versions
    versions = []
    rev_list.each do |sha|
      version = version_for_sha sha
      unless versions.include? version or version.nil?
        yield version, sha if block_given?
        versions << version
      end
    end
    return versions
  end

  def bottle_filenames branch='HEAD'
    filenames = []
    rev_list(branch).each do |sha|
      filename = formula_for_sha(sha) {|f| bottle_filename f if f.bottle }
      unless filenames.include? filename or filename.nil?
        filenames << filename
      end
    end
    return filenames
  end

  def pretty_relative_path
    if Pathname.pwd == repository
      entry_name
    else
      repository/"#{entry_name}"
    end
  end

  private
    def repository
      @repository ||= begin
        if path.realpath.to_s =~ %r{#{HOMEBREW_REPOSITORY}/Library/Taps/(\w+)-(\w+)}
          HOMEBREW_REPOSITORY/"Library/Taps/#$1-#$2"
        else
          HOMEBREW_REPOSITORY
        end
      end
    end

    def entry_name
      @entry_name ||= begin
        repository == HOMEBREW_REPOSITORY ? "Library/Formula/#{name}.rb" : "#{name}.rb"
      end
{'fraction_non_alphanumeric': 0.09782001117942984, 'fraction_numerical': 0.0016769144773616546, 'mean_word_length': 2.2986175115207375, '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': '7297620', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1142, 'n_words': 290}