mirror of
https://github.com/Homebrew/brew.git
synced 2026-08-12 22:29:27 +04:00
Apply utils/popen suggestions
This commit is contained in:
@@ -238,7 +238,7 @@ module Homebrew
|
||||
.filter_map do |filestub|
|
||||
if filestub.start_with?("test/")
|
||||
# Only run tests on *_spec.rb files in test/ folder
|
||||
filestub.end_with?("_spec") ? Pathname("#{filestub}.rb") : nil
|
||||
Pathname("#{filestub}.rb") if filestub.end_with?("_spec")
|
||||
else
|
||||
# For all other changed .rb files guess the associated test file name
|
||||
Pathname("test/#{filestub}_spec.rb")
|
||||
|
||||
@@ -61,7 +61,7 @@ module Homebrew
|
||||
Utils.popen_read("git", "rev-list", "-n1", "--before=#{date}", "origin/main").chomp
|
||||
elsif args.to_tag?
|
||||
tags = git_tags
|
||||
current_tag, previous_tag, = T.must(tags).lines
|
||||
current_tag, previous_tag, = tags.lines
|
||||
current_tag = current_tag.to_s.chomp
|
||||
odie "Could not find current tag in:\n#{tags}" if current_tag.empty?
|
||||
# ^0 ensures this points to the commit rather than the tag object.
|
||||
@@ -142,7 +142,7 @@ module Homebrew
|
||||
|
||||
private
|
||||
|
||||
sig { returns(T.nilable(String)) }
|
||||
sig { returns(String) }
|
||||
def git_tags
|
||||
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
|
||||
if tags.blank?
|
||||
@@ -151,6 +151,7 @@ module Homebrew
|
||||
Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
|
||||
end
|
||||
end
|
||||
odie "Could not find git tags!" if tags.blank?
|
||||
tags
|
||||
end
|
||||
end
|
||||
|
||||
@@ -100,11 +100,13 @@ module Hardware
|
||||
|
||||
sig { returns(Integer) }
|
||||
def cores
|
||||
return @cores if @cores
|
||||
|
||||
@cores = T.let(Utils.popen_read("getconf", "_NPROCESSORS_ONLN").chomp.to_i, T.nilable(Integer))
|
||||
@cores = 1 unless $CHILD_STATUS.success?
|
||||
T.must(@cores)
|
||||
@cores ||= T.let(
|
||||
begin
|
||||
cores = Utils.popen_read("getconf", "_NPROCESSORS_ONLN").chomp.to_i
|
||||
$CHILD_STATUS.success? ? cores : 1
|
||||
end,
|
||||
T.nilable(Integer),
|
||||
)
|
||||
end
|
||||
|
||||
sig { returns(T.nilable(Integer)) }
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "utils/output"
|
||||
|
||||
class Keg
|
||||
extend Utils::Output::Mixin
|
||||
|
||||
PREFIX_PLACEHOLDER = T.let("@@HOMEBREW_PREFIX@@", String)
|
||||
CELLAR_PLACEHOLDER = T.let("@@HOMEBREW_CELLAR@@", String)
|
||||
REPOSITORY_PLACEHOLDER = T.let("@@HOMEBREW_REPOSITORY@@", String)
|
||||
@@ -420,11 +424,12 @@ class Keg
|
||||
next unless str.match? path_regex
|
||||
|
||||
offset, match = str.split(" ", 2)
|
||||
odie "Failed to parse strings output: #{str.inspect}" unless match
|
||||
|
||||
# Some binaries contain strings with lists of files
|
||||
# e.g. `/usr/local/lib/foo:/usr/local/share/foo:/usr/lib/foo`
|
||||
# Each item in the list should be checked separately
|
||||
T.must(match).split(":").each do |sub_match|
|
||||
match.split(":").each do |sub_match|
|
||||
# Not all items in the list may be matches
|
||||
next unless sub_match.match? path_regex
|
||||
next if linked_libraries.include? sub_match # Don't bother reporting a string if it was found by otool
|
||||
|
||||
@@ -13,6 +13,8 @@ module OS
|
||||
raise "Loaded OS::Linux on macOS!" if OS.mac?
|
||||
# rubocop:enable Homebrew/MoveToExtendOS
|
||||
|
||||
extend Utils::Output::Mixin
|
||||
|
||||
@languages = T.let([], T::Array[String])
|
||||
|
||||
# Get the OS version.
|
||||
@@ -22,7 +24,10 @@ module OS
|
||||
def self.os_version
|
||||
if which("lsb_release")
|
||||
lsb_info = Utils.popen_read("lsb_release", "-a")
|
||||
description = T.must(lsb_info[/^Description:\s*(.*)$/, 1]).force_encoding("UTF-8")
|
||||
description = lsb_info[/^Description:\s*(.*)$/, 1]&.force_encoding("UTF-8")
|
||||
|
||||
odie "Failed to parse lsb_release output: #{lsb_info.inspect}" unless description
|
||||
|
||||
codename = lsb_info[/^Codename:\s*(.*)$/, 1]
|
||||
if codename.blank? || (codename == "n/a")
|
||||
description
|
||||
|
||||
@@ -3,7 +3,12 @@
|
||||
# This file contains temporary definitions for fixes that have
|
||||
# been submitted upstream to https://github.com/sorbet/sorbet.
|
||||
|
||||
# https://github.com/sorbet/sorbet/pull/9847
|
||||
class IO
|
||||
sig { params(timeout: T.any(Float, Integer)).returns(IO) }
|
||||
def wait_readable(timeout = T.unsafe(nil)); end
|
||||
# Waits until IO is readable and returns a truthy value, or a falsy value when
|
||||
# times out. Returns a truthy value immediately when buffered data is available.
|
||||
#
|
||||
# You must require 'io/wait' to use this method.
|
||||
sig { params(timeout: T.nilable(T.any(Float, Integer, Rational))).returns(T.nilable(T.any(IO, T::Boolean))) }
|
||||
def wait_readable(timeout = nil); end
|
||||
end
|
||||
|
||||
@@ -706,7 +706,7 @@ module GitHub
|
||||
if args.no_fork? || args.write_only?
|
||||
remote_url = Utils.popen_read("git", "remote", "get-url", "--push", "origin").chomp
|
||||
username = tap.user
|
||||
add_auth_token_to_url!(T.must(remote_url))
|
||||
add_auth_token_to_url!(remote_url)
|
||||
else
|
||||
begin
|
||||
url, username = forked_repo_info!(tap_remote_repo, org: args.fork_org)
|
||||
@@ -716,7 +716,8 @@ module GitHub
|
||||
end
|
||||
odie "Unable to fork: #{e.message}!"
|
||||
end
|
||||
remote_url = T.must(url)
|
||||
odie "Failed to get forked repository URL for #{tap_remote_repo}!" unless url
|
||||
remote_url = url
|
||||
end
|
||||
|
||||
next if args.dry_run?
|
||||
|
||||
Reference in New Issue
Block a user