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:
		
							parent
							
								
									47ef066344
								
							
						
					
					
						commit
						572c7cd179
					
				@ -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? ==
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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"
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user