@@ -10,7 +10,7 @@ class FormulaeDetect < Test
1010 sig {
1111 params (
1212 argument : String ,
13- tap : T . nilable ( Tap ) ,
13+ tap : Tap ,
1414 git : String ,
1515 dry_run : T ::Boolean ,
1616 fail_fast : T ::Boolean ,
@@ -25,6 +25,7 @@ def initialize(argument, tap:, git:, dry_run:, fail_fast:, verbose:)
2525 @deleted_formulae = T . let ( [ ] , T ::Array [ String ] )
2626 @formulae_to_fetch = T . let ( [ ] , T ::Array [ String ] )
2727 @testing_formulae = T . let ( [ ] , T ::Array [ String ] )
28+ @tap = T . let ( tap , Tap )
2829 end
2930
3031 sig { params ( args : Homebrew ::Cmd ::TestBotCmd ::Args ) . void }
@@ -83,10 +84,10 @@ def detect_formulae!(args:)
8384 No known CI provider detected! If you are using GitHub Actions then we cannot find the expected environment variables! Check you have e.g. exported them to a Docker container.
8485 EOS
8586 end
86- elsif tap . present? && T . must ( tap ) . full_name . casecmp ( github_repository ) &.zero?
87+ elsif @ tap. full_name . casecmp ( github_repository ) &.zero?
8788 # Use GitHub Actions variables for pull request jobs.
8889 if ( base_ref = ENV . fetch ( "GITHUB_BASE_REF" , nil ) ) . present?
89- unless T . must ( tap ) . official?
90+ unless @ tap. official?
9091 test git . to_s , "-C" , repository . to_s , "fetch" ,
9192 "origin" , "+refs/heads/#{ base_ref } "
9293 end
@@ -100,7 +101,7 @@ def detect_formulae!(args:)
100101 diff_end_sha1 = github_sha
101102 # Use GitHub Actions variables for branch jobs.
102103 else
103- test git . to_s , "-C" , repository . to_s , "fetch" , "origin" , "+#{ github_ref } " unless T . must ( tap ) . official?
104+ test git . to_s , "-C" , repository . to_s , "fetch" , "origin" , "+#{ github_ref } " unless @ tap. official?
104105 origin_ref = "origin/#{ github_ref . gsub ( %r{^refs/heads/} , "" ) } "
105106 diff_end_sha1 = diff_start_sha1 = github_sha
106107 end
@@ -120,15 +121,15 @@ def detect_formulae!(args:)
120121
121122 if tap
122123 tap_origin_ref_revision_args =
123- [ git , "-C" , T . must ( tap ) . path . to_s , "log" , "-1" , "--format=%h (%s)" , origin_ref ]
124+ [ git , "-C" , @ tap. path . to_s , "log" , "-1" , "--format=%h (%s)" , origin_ref ]
124125 tap_origin_ref_revision = if args . dry_run?
125126 # May fail on dry run as we've not fetched.
126127 Utils . popen_read ( *tap_origin_ref_revision_args ) . strip
127128 else
128129 Utils . safe_popen_read ( *tap_origin_ref_revision_args )
129130 end . strip
130131 tap_revision = Utils . safe_popen_read (
131- git , "-C" , T . must ( tap ) . path . to_s ,
132+ git , "-C" , @ tap. path . to_s ,
132133 "log" , "-1" , "--format=%h (%s)"
133134 ) . strip
134135 end
@@ -143,8 +144,8 @@ def detect_formulae!(args:)
143144
144145 modified_formulae = [ ]
145146
146- if tap && diff_start_sha1 != diff_end_sha1
147- formula_path = T . must ( tap ) . formula_dir . to_s
147+ if diff_start_sha1 != diff_end_sha1
148+ formula_path = @ tap. formula_dir . to_s
148149 @added_formulae +=
149150 diff_formulae ( diff_start_sha1 , diff_end_sha1 , formula_path , "A" )
150151 modified_formulae +=
@@ -255,17 +256,15 @@ def current_sha1
255256 ) . returns ( T ::Array [ String ] )
256257 }
257258 def diff_formulae ( start_revision , end_revision , path , filter )
258- raise "A tap is required to call diff_formulae" unless tap
259-
260259 Utils . safe_popen_read (
261260 git , "-C" , repository ,
262261 "diff-tree" , "-r" , "--name-only" , "--diff-filter=#{ filter } " ,
263262 start_revision , end_revision , "--" , path
264263 ) . lines ( chomp : true ) . filter_map do |file |
265- next unless T . must ( tap ) . formula_file? ( file )
264+ next unless @ tap. formula_file? ( file )
266265
267266 file = Pathname . new ( file )
268- T . must ( tap ) . formula_file_to_name ( file )
267+ @ tap. formula_file_to_name ( file )
269268 end
270269 end
271270 end
0 commit comments