formula: make each instance have separate spec references

This fixes SoftwareSpec#owner being mixed up if there are multiple formula references.
This in turn fixes --force-bottle not working in some scenarios like `brew reinstall`.
This commit is contained in:
Bo Anderson 2021-10-26 15:03:29 +01:00
parent 47ef066344
commit 572c7cd179
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
2 changed files with 11 additions and 3 deletions

View File

@ -262,7 +262,7 @@ class Formula
end
def spec_eval(name)
spec = self.class.send(name)
spec = self.class.send(name).dup
return unless spec.url
spec.owner = self
@ -1449,9 +1449,9 @@ class Formula
# @private
def ==(other)
instance_of?(other.class) &&
self.class == other.class &&
name == other.name &&
active_spec == other.active_spec
active_spec_sym == other.active_spec_sym
end
alias eql? ==

View File

@ -567,6 +567,14 @@ describe Formula do
expect(f.class.head).to be_kind_of(SoftwareSpec)
end
specify "instance specs have different references" do
f = Testball.new
f2 = Testball.new
expect(f.stable.owner).to equal(f)
expect(f2.stable.owner).to equal(f2)
end
specify "incomplete instance specs are not accessible" do
f = formula do
url "foo-1.0"