<commit_before># typed: true
# frozen_string_literal: true

require "cli/parser"
require "formula"

module Homebrew
  extend T::Sig

  module_function

  sig { returns(CLI::Parser) }
  def untap_args
    Homebrew::CLI::Parser.new do
      usage_banner <<~EOS
        `untap` <tap>

        Remove a tapped formula repository.
      EOS
      switch "-f", "--force",
             description: "Untap even if formulae or casks from this tap are currently installed."

      min_named 1
    end
  end

  def untap
    args = untap_args.parse

    args.named.each do |tapname|
      tap = Tap.fetch(tapname)
      odie "Untapping #{tap} is not allowed" if tap.core_tap?

      installed_tap_formulae = Formula.installed.select { |formula| formula.tap == tap }
      installed_tap_casks = Cask::Caskroom.casks.select { |cask| cask.tap == tap }

      if installed_tap_formulae.length.positive? || installed_tap_casks.length.positive?
        if args.force?
          opoo "Untapping #{tap} even though it contains formulae or casks that are currently installed."
        else
          odie <<~EOS
            Refusing to untap #{tap} because it contains the following installed formulae or casks:
            #{(installed_tap_formulae + installed_tap_casks.map(&:token)).join("\n")}
          EOS
        end
      end

      tap.uninstall
    end
  end
end<commit_msg>untap: add --force switch<commit_after># typed: true
# frozen_string_literal: true

require "cli/parser"
require "formula"

module Homebrew
  extend T::Sig

  module_function

  sig { returns(CLI::Parser) }
  def untap_args
    Homebrew::CLI::Parser.new do
      usage_banner <<~EOS
        `untap` <tap>

        Remove a tapped formula repository.
      EOS
      switch "-f", "--force",
             description: "Untap even if formulae or casks from this tap are currently installed."

      min_named 1
    end
  end

  def untap
    args = untap_args.parse

    args.named.each do |tapname|
      tap = Tap.fetch(tapname)
      odie "Untapping #{tap} is not allowed" if tap.core_tap?

      installed_tap_formulae = Formula.installed.select { |formula| formula.tap == tap }
      installed_tap_casks = Cask::Caskroom.casks.select { |cask| cask.tap == tap }

      if installed_tap_formulae.length.positive? || installed_tap_casks.length.positive?
        if args.force?
          opoo <<~EOS
            Untapping #{tap} even though it contains the following installed formulae or casks:
            #{(installed_tap_formulae + installed_tap_casks.map(&:token)).join("\n")}
          EOS
        else
          odie <<~EOS
            Refusing to untap #{tap} because it contains the following installed formulae or casks:
            #{(installed_tap_formulae + installed_tap_casks.map(&:token)).join("\n")}
          EOS
        end
      end

      tap.uninstall
    end
  end
end
{'fraction_non_alphanumeric': 0.0956552207428171, 'fraction_numerical': 0.000700770847932726, 'mean_word_length': 2.5334158415841586, 'pattern_counts': {'":': 0, '<': 15, '<?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': '4012935', 'n_tokens_mistral': 962, 'n_tokens_neox': 869, 'n_words': 247}