mirror of
https://github.com/Homebrew/brew.git
synced 2024-11-25 16:33:34 +08:00
Merge pull request #18783 from bevanjkay/generate-cask-ci-matrix-fix
generate-cask-ci-matrix: fix incorrect error being raised
This commit is contained in:
commit
7de8d2d876
@ -48,15 +48,6 @@ module Homebrew
|
||||
hide_from_man_page!
|
||||
end
|
||||
|
||||
sig { params(args: T::Array[String]).void }
|
||||
def initialize(*args)
|
||||
super
|
||||
repository = ENV.fetch("GITHUB_REPOSITORY", "homebrew/homebrew-cask")
|
||||
raise UsageError, "The GITHUB_REPOSITORY environment variable must be set." if repository.blank?
|
||||
|
||||
@tap = T.let(Tap.fetch(repository), Tap)
|
||||
end
|
||||
|
||||
sig { override.void }
|
||||
def run
|
||||
skip_install = args.skip_install?
|
||||
@ -64,14 +55,17 @@ module Homebrew
|
||||
casks = args.named if args.casks?
|
||||
pr_url = args.named if args.url?
|
||||
syntax_only = args.syntax_only?
|
||||
tap = @tap
|
||||
|
||||
repository = ENV.fetch("GITHUB_REPOSITORY", nil)
|
||||
raise UsageError, "The GITHUB_REPOSITORY environment variable must be set." if repository.blank?
|
||||
|
||||
tap = T.let(Tap.fetch(repository), Tap)
|
||||
|
||||
raise UsageError, "Either `--cask` or `--url` must be specified." if casks.blank? && pr_url.blank?
|
||||
raise UsageError, "Only one url can be specified" if pr_url&.count&.> 1
|
||||
raise UsageError, "This command must be run from inside a tap directory." if Dir.pwd.to_s != tap.path.to_s
|
||||
|
||||
labels = if pr_url
|
||||
pr = GitHub::API.open_rest(pr_url)
|
||||
pr = GitHub::API.open_rest(pr_url.first)
|
||||
pr.fetch("labels").map { |l| l.fetch("name") }
|
||||
else
|
||||
[]
|
||||
@ -225,7 +219,7 @@ module Homebrew
|
||||
def generate_matrix(tap, labels: [], cask_names: [], skip_install: false, new_cask: false)
|
||||
odie "This command must be run from inside a tap directory." unless tap
|
||||
|
||||
changed_files = find_changed_files
|
||||
changed_files = find_changed_files(tap)
|
||||
|
||||
ruby_files_in_wrong_directory =
|
||||
T.must(changed_files[:modified_ruby_files]) - (
|
||||
@ -310,10 +304,8 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
sig { returns(T::Hash[Symbol, T::Array[String]]) }
|
||||
def find_changed_files
|
||||
tap = @tap
|
||||
|
||||
sig { params(tap: Tap).returns(T::Hash[Symbol, T::Array[String]]) }
|
||||
def find_changed_files(tap)
|
||||
commit_range_start = Utils.safe_popen_read("git", "rev-parse", "origin").chomp
|
||||
commit_range_end = Utils.safe_popen_read("git", "rev-parse", "HEAD").chomp
|
||||
commit_range = "#{commit_range_start}...#{commit_range_end}"
|
||||
|
@ -4,15 +4,5 @@ require "cmd/shared_examples/args_parse"
|
||||
require "dev-cmd/generate-cask-ci-matrix"
|
||||
|
||||
RSpec.describe Homebrew::DevCmd::GenerateCaskCiMatrix do
|
||||
ENV["GITHUB_REPOSITORY"] = "homebrew/homebrew-cask"
|
||||
|
||||
it_behaves_like "parseable arguments"
|
||||
|
||||
it "fails when not from inside a tap directory", :integration_test do
|
||||
expect do
|
||||
brew "generate-cask-ci-matrix", "--cask", "google-chrome",
|
||||
"GITHUB_REPOSITORY" => ENV.fetch("GITHUB_REPOSITORY")
|
||||
end
|
||||
.to output(/Error: Invalid usage: This command must be run from inside a tap directory./).to_stderr
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user