Skip to content

Commit

Permalink
cmd/unbottled: Address review feedback for --lost
Browse files Browse the repository at this point in the history
- Add heading message to indicate bottle tag used
- Use --no-ext-diff with git to avoid potential problems
- Resolve formula renames to avoid false positives
- Increase parsing stringency
  • Loading branch information
apainintheneck committed Oct 17, 2023
1 parent 20f00a6 commit 83598bb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Library/Homebrew/dev-cmd/unbottled.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,10 @@ def output_unbottled(formulae, deps_hash, noun, hash, any_named_args)
end

def output_lost_bottles
# $ git log --patch -G\^\ \+sha256.\*\ sonoma: --since=@\{\'1\ week\ ago\'\}
git_log = %w[git log --patch]
ohai ":#{@bottle_tag} lost bottles"

Check warning on line 261 in Library/Homebrew/dev-cmd/unbottled.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/unbottled.rb#L261

Added line #L261 was not covered by tests

# $ git log --patch -G'^ +sha256.* sonoma:' --since=@{'1 week ago'}
git_log = %w[git log --patch --no-ext-diff]
git_log << "-G^ +sha256.* #{@bottle_tag}:"
git_log << "--since=@{'1 week ago'}"

Check warning on line 266 in Library/Homebrew/dev-cmd/unbottled.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/unbottled.rb#L264-L266

Added lines #L264 - L266 were not covered by tests

Expand All @@ -276,15 +278,17 @@ def output_lost_bottles
case line
when /^commit [0-9a-f]{40}$/
# Example match: `commit 7289b409b96a752540befef1a56b8a818baf1db7`
if commit && lost_bottles.positive? && processed_formulae.exclude?(formula)
if commit && formula && lost_bottles.positive? && processed_formulae.exclude?(formula)
puts "#{commit}: bottle lost for #{formula}"
end
processed_formulae << formula
commit = line.split.last
lost_bottles = 0
formula = nil

Check warning on line 286 in Library/Homebrew/dev-cmd/unbottled.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/unbottled.rb#L284-L286

Added lines #L284 - L286 were not covered by tests
when %r{^diff --git a/Formula/}
# Example match: `diff --git a/Formula/a/aws-cdk.rb b/Formula/a/aws-cdk.rb`
formula = line.split("/").last.chomp(".rb\n")
formula = CoreTap.instance.formula_renames.fetch(formula, formula)
lost_bottles = 0

Check warning on line 291 in Library/Homebrew/dev-cmd/unbottled.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/unbottled.rb#L290-L291

Added lines #L290 - L291 were not covered by tests
when bottle_tag_sha_regex
# Example match: `- sha256 cellar: :any_skip_relocation, sonoma: "f0a4..."`
next if processed_formulae.include?(formula)
Expand All @@ -301,7 +305,7 @@ def output_lost_bottles
end
end

return if !commit || !lost_bottles.positive? || processed_formulae.include?(formula)
return if !commit || !formula || !lost_bottles.positive? || processed_formulae.include?(formula)

puts "#{commit}: bottle lost for #{formula}"

Check warning on line 310 in Library/Homebrew/dev-cmd/unbottled.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/unbottled.rb#L310

Added line #L310 was not covered by tests
end
Expand Down

0 comments on commit 83598bb

Please sign in to comment.