use odie when commands encounter errors
This commit is contained in:
		
							parent
							
								
									a72ddfdc67
								
							
						
					
					
						commit
						2e982cd2a2
					
				@ -103,7 +103,7 @@ module Homebrew
 | 
			
		||||
        logs[file.basename.to_s] = { content: contents }
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    raise "No logs." if logs.empty?
 | 
			
		||||
    odie "No logs." if logs.empty?
 | 
			
		||||
 | 
			
		||||
    logs
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -183,14 +183,14 @@ module Homebrew
 | 
			
		||||
    formulae.each do |f|
 | 
			
		||||
      # head-only without --HEAD is an error
 | 
			
		||||
      if !args.HEAD? && f.stable.nil?
 | 
			
		||||
        raise <<~EOS
 | 
			
		||||
        odie <<~EOS
 | 
			
		||||
          #{f.full_name} is a head-only formula
 | 
			
		||||
          Install with `brew install --HEAD #{f.full_name}`
 | 
			
		||||
        EOS
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      # --HEAD, fail with no head defined
 | 
			
		||||
      raise "No head is defined for #{f.full_name}" if args.HEAD? && f.head.nil?
 | 
			
		||||
      odie "No head is defined for #{f.full_name}" if args.HEAD? && f.head.nil?
 | 
			
		||||
 | 
			
		||||
      installed_head_version = f.latest_head_version
 | 
			
		||||
      if installed_head_version &&
 | 
			
		||||
 | 
			
		||||
@ -31,7 +31,8 @@ module Homebrew
 | 
			
		||||
      if f.oldname
 | 
			
		||||
        rack = HOMEBREW_CELLAR/f.oldname
 | 
			
		||||
        raise NoSuchKegError, f.oldname if !rack.exist? || rack.subdirs.empty?
 | 
			
		||||
        raise "#{rack} is a symlink" if rack.symlink?
 | 
			
		||||
 | 
			
		||||
        odie "#{rack} is a symlink" if rack.symlink?
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      migrator = Migrator.new(f, force: args.force?)
 | 
			
		||||
 | 
			
		||||
@ -136,7 +136,7 @@ module Homebrew
 | 
			
		||||
        puts reason
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      raise "No formulae or casks found for #{query.inspect}." if count.zero?
 | 
			
		||||
      odie "No formulae or casks found for #{query.inspect}." if count.zero?
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    return unless $stdout.tty?
 | 
			
		||||
 | 
			
		||||
@ -180,7 +180,7 @@ module Homebrew
 | 
			
		||||
    # unless --force is specified.
 | 
			
		||||
    unless args.force?
 | 
			
		||||
      if reason = MissingFormula.disallowed_reason(fc.name)
 | 
			
		||||
        raise <<~EOS
 | 
			
		||||
        odie <<~EOS
 | 
			
		||||
          The formula '#{fc.name}' is not allowed to be created.
 | 
			
		||||
          #{reason}
 | 
			
		||||
          If you really want to create this formula use `--force`.
 | 
			
		||||
@ -189,7 +189,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
      if Formula.aliases.include? fc.name
 | 
			
		||||
        realname = Formulary.canonical_name(fc.name)
 | 
			
		||||
        raise <<~EOS
 | 
			
		||||
        odie <<~EOS
 | 
			
		||||
          The formula '#{realname}' is already aliased to '#{fc.name}'.
 | 
			
		||||
          Please check that you are not creating a duplicate.
 | 
			
		||||
          To force creation use `--force`.
 | 
			
		||||
 | 
			
		||||
@ -32,7 +32,7 @@ module Homebrew
 | 
			
		||||
    args = edit_args.parse
 | 
			
		||||
 | 
			
		||||
    unless (HOMEBREW_REPOSITORY/".git").directory?
 | 
			
		||||
      raise <<~EOS
 | 
			
		||||
      odie <<~EOS
 | 
			
		||||
        Changes will be lost!
 | 
			
		||||
        The first time you `brew update`, all local changes will be lost; you should
 | 
			
		||||
        thus `brew update` before you `brew edit`!
 | 
			
		||||
 | 
			
		||||
@ -340,7 +340,7 @@ module Homebrew
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def download_artifact(url, dir, pr)
 | 
			
		||||
    raise "Credentials must be set to access the Artifacts API" if GitHub.api_credentials_type == :none
 | 
			
		||||
    odie "Credentials must be set to access the Artifacts API" if GitHub.api_credentials_type == :none
 | 
			
		||||
 | 
			
		||||
    token = GitHub.api_credentials
 | 
			
		||||
    curl_args = ["--header", "Authorization: token #{token}"]
 | 
			
		||||
 | 
			
		||||
@ -37,7 +37,7 @@ module Homebrew
 | 
			
		||||
    branch = args.branch || "main"
 | 
			
		||||
 | 
			
		||||
    tap = args.named.to_taps.first
 | 
			
		||||
    raise "Invalid tap name '#{tap_name}'" unless tap.path.to_s.match?(HOMEBREW_TAP_PATH_REGEX)
 | 
			
		||||
    odie "Invalid tap name '#{tap_name}'" unless tap.path.to_s.match?(HOMEBREW_TAP_PATH_REGEX)
 | 
			
		||||
 | 
			
		||||
    titleized_user = tap.user.dup
 | 
			
		||||
    titleized_repo = tap.repo.dup
 | 
			
		||||
@ -169,7 +169,7 @@ module Homebrew
 | 
			
		||||
  def write_path(tap, filename, content)
 | 
			
		||||
    path = tap.path/filename
 | 
			
		||||
    tap.path.mkpath
 | 
			
		||||
    raise "#{path} already exists" if path.exist?
 | 
			
		||||
    odie "#{path} already exists" if path.exist?
 | 
			
		||||
 | 
			
		||||
    path.write content
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -45,13 +45,13 @@ module Homebrew
 | 
			
		||||
      unpack_dir = Pathname.pwd
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    raise "Cannot write to #{unpack_dir}" unless unpack_dir.writable_real?
 | 
			
		||||
    odie "Cannot write to #{unpack_dir}" unless unpack_dir.writable_real?
 | 
			
		||||
 | 
			
		||||
    formulae.each do |f|
 | 
			
		||||
      stage_dir = unpack_dir/"#{f.name}-#{f.version}"
 | 
			
		||||
 | 
			
		||||
      if stage_dir.exist?
 | 
			
		||||
        raise "Destination #{stage_dir} already exists!" unless args.force?
 | 
			
		||||
        odie "Destination #{stage_dir} already exists!" unless args.force?
 | 
			
		||||
 | 
			
		||||
        rm_rf stage_dir
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@ -134,7 +134,7 @@ module Homebrew
 | 
			
		||||
        start_log = Utils.popen_read("git", "log", "-1", "--decorate", "--oneline", start_commit).chomp
 | 
			
		||||
        end_log = Utils.popen_read("git", "log", "-1", "--decorate", "--oneline", end_commit).chomp
 | 
			
		||||
        actual_log = Utils.popen_read("git", "log", "-1", "--decorate", "--oneline", actual_end_commit).chomp
 | 
			
		||||
        raise <<~EOS
 | 
			
		||||
        odie <<~EOS
 | 
			
		||||
          brew update didn't update #{branch}!
 | 
			
		||||
          Start commit:        #{start_log}
 | 
			
		||||
          Expected end commit: #{end_log}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user