Skip to content

Commit

Permalink
dev-cmd/bottle: fix Rubocop warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcQuaid committed Sep 11, 2016
1 parent 264afb6 commit 9b5c45a
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions Library/Homebrew/dev-cmd/bottle.rb
Expand Up @@ -13,7 +13,7 @@
require "erb"
require "extend/pathname"

BOTTLE_ERB = <<-EOS
BOTTLE_ERB = <<-EOS.freeze
bottle do
<% if !root_url.start_with?(BottleSpecification::DEFAULT_DOMAIN) %>
root_url "<%= root_url %>"
Expand Down Expand Up @@ -89,15 +89,14 @@ def print_filename(string, filename)
end
end

if ARGV.verbose? && !text_matches.empty?
print_filename string, file
text_matches.first(MAXIMUM_STRING_MATCHES).each do |match, offset|
puts " #{Tty.gray}-->#{Tty.reset} match '#{match}' at offset #{Tty.em}0x#{offset}#{Tty.reset}"
end
next unless ARGV.verbose? && !text_matches.empty?
print_filename string, file
text_matches.first(MAXIMUM_STRING_MATCHES).each do |match, offset|
puts " #{Tty.gray}-->#{Tty.reset} match '#{match}' at offset #{Tty.em}0x#{offset}#{Tty.reset}"
end

if text_matches.size > MAXIMUM_STRING_MATCHES
puts "Only the first #{MAXIMUM_STRING_MATCHES} matches were output"
end
if text_matches.size > MAXIMUM_STRING_MATCHES
puts "Only the first #{MAXIMUM_STRING_MATCHES} matches were output"
end
end

Expand All @@ -107,10 +106,9 @@ def print_filename(string, filename)
def keg_contain_absolute_symlink_starting_with?(string, keg)
absolute_symlinks_start_with_string = []
keg.find do |pn|
if pn.symlink? && (link = pn.readlink).absolute?
if link.to_s.start_with?(string)
absolute_symlinks_start_with_string << pn
end
next unless pn.symlink? && (link = pn.readlink).absolute?
if link.to_s.start_with?(string)
absolute_symlinks_start_with_string << pn
end
end

Expand Down Expand Up @@ -146,7 +144,7 @@ def bottle_formula(f)
return
end

unless Utils::Bottles::built_as? f
unless Utils::Bottles.built_as? f
return ofail "Formula not installed with '--build-bottle': #{f.full_name}"
end

Expand Down Expand Up @@ -289,6 +287,9 @@ def bottle_formula(f)
bottle.sha256 sha256 => Utils::Bottles.tag

old_spec = f.bottle_specification
p root_url
p old_spec.root_url(root_url)
p bottle.root_url(root_url)

This comment has been minimized.

Copy link
@zmwangx

zmwangx Sep 12, 2016

Contributor

Hmm, are these debug statements?

This comment has been minimized.

Copy link
@MikeMcQuaid

MikeMcQuaid Sep 12, 2016

Author Member

Yes: #942

if ARGV.include?("--keep-old") && !old_spec.checksums.empty?
mismatches = [:root_url, :prefix, :cellar, :rebuild].select do |key|
old_spec.send(key) != bottle.send(key)
Expand Down Expand Up @@ -332,7 +333,7 @@ def bottle_formula(f)
"filename" => filename.to_s,
"sha256" => sha256,
},
}
},
},
"bintray" => {
"package" => Utils::Bottles::Bintray.package(f.name),
Expand Down Expand Up @@ -372,7 +373,7 @@ def merge
output = bottle_output bottle

if write
path = Pathname.new("#{HOMEBREW_REPOSITORY/bottle_hash["formula"]["path"]}")
path = Pathname.new((HOMEBREW_REPOSITORY/bottle_hash["formula"]["path"]).to_s)
update_or_add = nil

Utils::Inreplace.inreplace(path) do |s|
Expand All @@ -391,7 +392,7 @@ def merge
old_value = old_value_original.to_s.delete ":'\""
tag = tag.to_s.delete ":"

if !tag.empty?
unless tag.empty?
if !bottle_hash["bottle"]["tags"][tag].to_s.empty?
mismatches << "#{key} => #{tag}"
else
Expand All @@ -403,11 +404,10 @@ def merge
value_original = bottle_hash["bottle"][key]
value = value_original.to_s
next if key == "cellar" && old_value == "any" && value == "any_skip_relocation"
if old_value.empty? || value != old_value
old_value = old_value_original.inspect
value = value_original.inspect
mismatches << "#{key}: old: #{old_value}, new: #{value}"
end
next unless old_value.empty? || value != old_value
old_value = old_value_original.inspect
value = value_original.inspect
mismatches << "#{key}: old: #{old_value}, new: #{value}"
end

unless mismatches.empty?
Expand Down Expand Up @@ -444,7 +444,8 @@ def merge
rebuild\ \d+ # rebuild with a number
)\n+ # multiple empty lines
)+
/mx, '\0' + output + "\n")
/mx, '\0' + output + "\n"
)
end
odie "Bottle block addition failed!" unless string
end
Expand Down

3 comments on commit 9b5c45a

@zmwangx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MikeMcQuaid
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zmwangx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sample output:

 ==> Bottling pygobject-2.28.6_1.sierra.bottle.tar.gz...
/usr/bin/touch -h -t 201106131735.44 /usr/local/Cellar/pygobject/2.28.6_1/lib/libpyglib-2.0-python.dylib
tar cf /Users/brew/Jenkins/testing-10-11/version/sierra_2/pygobject-2.28.6_1.sierra.bottle.tar pygobject/2.28.6_1
gzip -f pygobject-bottle.tar
nil
"https://homebrew.bintray.com/bottles"
"https://homebrew.bintray.com/bottles"
./pygobject-2.28.6_1.sierra.bottle.json
  bottle do
    cellar :any
    sha256 "9a10d979f637cfc9abc46839fa470672ee97a33be5f8ea9a8b725d44f60ed0ba" => :sierra
  end
 --keep-old
==> FAILED
Error: No such file or directory - ==> Bottling pygobject-2.28.6_1.sierra.bottle.tar.gz...
/usr/bin/touch -h -t 201106131735.44 /usr/local/Cellar/pygobject/2.28.6_1/lib/libpyglib-2.0-python.dylib
tar cf /Users/brew/Jenkins/testing-10-11/version/sierra_2/pygobject-2.28.6_1.sierra.bottle.tar pygobject/2.28.6_1
gzip -f pygobject-bottle.tar
nil
"https://homebrew.bintray.com/bottles"
"https://homebrew.bintray.com/bottles"
./pygobject-2.28.6_1.sierra.bottle.json
  bottle do
    cellar :any
    sha256 "9a10d979f637cfc9abc46839fa470672ee97a33be5f8ea9a8b725d44f60ed0ba" => :sierra
  end

There may be more to the story?

Please sign in to comment.