<commit_before>#:  * `migrate-formula` [--remote=<remote>] [--tap=<tap>] <formulae>:
#:    Migrate formulae to a new tap.
#:
#:    --remote=<remote> Use this GitHub remote, or $HOMEBREW_GITHUB_USER or $USER.
#:    --tap=<tap> Move formulae to this tap.

module Homebrew
  module_function

  def remote
    ARGV.value("remote") || ENV["HOMEBREW_GITHUB_USER"] || ENV["USER"]
  end

  def open_pull_request?(formula, tap)
    prs = GitHub.issues_for_formula(formula,
      type: "pr", state: "open", repo: tap.full_name)
    prs = prs.select { |pr| pr["title"].strip.start_with? "#{formula}: " }
    if prs.any?
      opoo "#{formula}: Skipping because a PR is open"
      prs.each { |pr| puts "#{pr["title"]} (#{pr["html_url"]})" }
    end
    prs.any?
  end

  def add_formula(formula, tap)
    dest = Pathname.new "#{tap.formula_dir}/#{formula.name}.rb"
    ohai "Migrating #{formula.full_name} to #{tap}"
    odie "Source and destination tap are the same." if formula.tap == tap
    unless Utils.popen_read("git", "ls-files", dest).empty?
      opoo "Skipping new formula PR because formula already exists: #{dest}"
      return
    end<commit_msg>migrate-formula: Call git with -C option (#83)<commit_after>#:  * `migrate-formula` [--remote=<remote>] [--tap=<tap>] <formulae>:
#:    Migrate formulae to a new tap.
#:
#:    --remote=<remote> Use this GitHub remote, or $HOMEBREW_GITHUB_USER or $USER.
#:    --tap=<tap> Move formulae to this tap.

module Homebrew
  module_function

  def remote
    ARGV.value("remote") || ENV["HOMEBREW_GITHUB_USER"] || ENV["USER"]
  end

  def open_pull_request?(formula, tap)
    prs = GitHub.issues_for_formula(formula,
      type: "pr", state: "open", repo: tap.full_name)
    prs = prs.select { |pr| pr["title"].strip.start_with? "#{formula}: " }
    if prs.any?
      opoo "#{formula}: Skipping because a PR is open"
      prs.each { |pr| puts "#{pr["title"]} (#{pr["html_url"]})" }
    end
    prs.any?
  end

  def add_formula(formula, tap)
    dest = Pathname.new "#{tap.formula_dir}/#{formula.name}.rb"
    ohai "Migrating #{formula.full_name} to #{tap}"
    odie "Source and destination tap are the same." if formula.tap == tap
    unless Utils.popen_read("git", "-C", tap.path, "ls-files", dest).empty?
      opoo "Skipping new formula PR because formula already exists: #{dest}"
      return
    end
{'fraction_non_alphanumeric': 0.16531742650191733, 'fraction_numerical': 0.0008521516829995739, 'mean_word_length': 3.5067178502879077, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '2983006', 'n_tokens_mistral': 896, 'n_tokens_neox': 830, 'n_words': 221}