extract: handle versioned formulae names

Turn the output versioned formula from the form "name@version" to
"name-version", then following by appending the specific version
after it.

This solution ensures that separate extracted versions of a formulae
can exist alongside each other (e.g. 'python-2@2.7.17' and
'python-2@2.7.16').
This commit is contained in:
Caleb Xu 2020-02-21 17:26:24 -05:00
parent 5ebc478727
commit fa5faf3895

View File

@ -180,6 +180,9 @@ module Homebrew
# The class name has to be renamed to match the new filename,
# e.g. Foo version 1.2.3 becomes FooAT123 and resides in Foo@1.2.3.rb.
class_name = Formulary.class_s(name)
# Remove any existing version suffixes, as a new one will be added later
name.sub!(/\b@(.*)\z\b/i, "")
versioned_name = Formulary.class_s("#{name}@#{version}")
result.gsub!("class #{class_name} < Formula", "class #{versioned_name} < Formula")