Merge pull request #4610 from reitermarkus/update-report
Fix `update-report` migration.
This commit is contained in:
		
						commit
						6fa5b19d9f
					
				@ -198,6 +198,8 @@ module Homebrew
 | 
			
		||||
      next unless /^(?<prefix>[^\.]+[^\-])\-(?<suffix>[^\-].*)/ =~ child.basename.to_s
 | 
			
		||||
      target = HOMEBREW_CACHE/"#{prefix}--#{suffix}"
 | 
			
		||||
 | 
			
		||||
      next if suffix.include?("--") && !suffix.start_with?("patch")
 | 
			
		||||
 | 
			
		||||
      if target.exist?
 | 
			
		||||
        begin
 | 
			
		||||
          FileUtils.rm_rf child
 | 
			
		||||
 | 
			
		||||
@ -16,6 +16,32 @@ describe "brew update-report" do
 | 
			
		||||
      expect(renamed_cache_file).to exist
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context "when the formula name contains dashes" do
 | 
			
		||||
      let(:legacy_cache_file) { HOMEBREW_CACHE/"foo-bar-1.2.3.tar.gz" }
 | 
			
		||||
      let(:renamed_cache_file) { HOMEBREW_CACHE/"foo-bar--1.2.3.tar.gz" }
 | 
			
		||||
 | 
			
		||||
      it "does not introduce extra double dashes when called multiple times" do
 | 
			
		||||
        Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
 | 
			
		||||
        Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
 | 
			
		||||
 | 
			
		||||
        expect(legacy_cache_file).not_to exist
 | 
			
		||||
        expect(renamed_cache_file).to exist
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context "when the file is a patch and the formula name contains dashes" do
 | 
			
		||||
      let(:legacy_cache_file) { HOMEBREW_CACHE/"foo-bar-patch--1.2.3.tar.gz" }
 | 
			
		||||
      let(:renamed_cache_file) { HOMEBREW_CACHE/"foo-bar--patch--1.2.3.tar.gz" }
 | 
			
		||||
 | 
			
		||||
      it "does not introduce extra double dashes when called multiple times" do
 | 
			
		||||
        Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
 | 
			
		||||
        Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
 | 
			
		||||
 | 
			
		||||
        expect(legacy_cache_file).not_to exist
 | 
			
		||||
        expect(renamed_cache_file).to exist
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "does not move files if upgrading from > 1.7.1" do
 | 
			
		||||
      Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.2"))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user